aboutsummaryrefslogtreecommitdiffstats
path: root/tosca-controlloop/runtime
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-04-29 09:33:24 +0100
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-05-07 16:14:40 +0100
commit65262f8dd9a6b9cbc284daa02ae332380e374483 (patch)
tree7e85493595c624c0e457bd0c8a7f85ffae71a864 /tosca-controlloop/runtime
parent15af7e7d708d3cbb5ae2bfbb75bdcd1810f214c5 (diff)
Update TOSCA PoC with changes from demo integration
This commit includes demo version changes for establishing a PMSH controlloop. Apologies for bringing a huge commit, this code is for the ControlLoop Demo, and it can act as base for the actual release. This framework is going to be completely changed including Spring framework for the future release. Please consider this code as base for any future work on controlloop. Issue-ID: POLICY-3215 Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech> Change-Id: I512626295d95ab32c29c6861375d31228d549ce9
Diffstat (limited to 'tosca-controlloop/runtime')
-rw-r--r--tosca-controlloop/runtime/pom.xml10
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java20
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java15
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java41
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java24
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java28
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java2
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java4
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java1
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java68
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java136
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java20
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java6
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java450
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java116
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java75
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java75
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java74
-rw-r--r--tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java53
-rw-r--r--tosca-controlloop/runtime/src/main/resources/META-INF/persistence.xml121
-rw-r--r--tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java7
-rw-r--r--tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java6
-rw-r--r--tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java55
-rw-r--r--tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java5
-rw-r--r--tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java2
-rw-r--r--tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java5
-rw-r--r--tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java2
-rw-r--r--tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java2
-rw-r--r--tosca-controlloop/runtime/src/test/resources/META-INF/persistence.xml99
-rw-r--r--tosca-controlloop/runtime/src/test/resources/parameters/CommissioningConfig.json20
-rw-r--r--tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParametersStd.json (renamed from tosca-controlloop/runtime/src/test/resources/parameters/ConfigParametersStd.json)2
-rw-r--r--tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json31
-rw-r--r--tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParameters_sim.json43
-rw-r--r--tosca-controlloop/runtime/src/test/resources/parameters/MinimumParametersH2.json59
-rw-r--r--tosca-controlloop/runtime/src/test/resources/parameters/TestParametersMariaDB.json79
-rw-r--r--tosca-controlloop/runtime/src/test/resources/parameters/Unreadable.json1
-rw-r--r--tosca-controlloop/runtime/src/test/resources/parameters/logback-test.xml42
-rw-r--r--tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json (renamed from tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsElementsNotFound.json)76
-rw-r--r--tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoops.json72
-rw-r--r--tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsNotFound.json72
-rw-r--r--tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsUpdate.json72
-rw-r--r--tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json142
-rw-r--r--tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml (renamed from tosca-controlloop/runtime/src/test/resources/servicetemplates/pmsh_multiple_cl_tosca.yaml)0
-rw-r--r--tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml452
-rw-r--r--tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml221
-rw-r--r--tosca-controlloop/runtime/src/test/resources/testscripts/listenOnTopic.sh31
46 files changed, 2519 insertions, 418 deletions
diff --git a/tosca-controlloop/runtime/pom.xml b/tosca-controlloop/runtime/pom.xml
index e37748066..8433438ff 100644
--- a/tosca-controlloop/runtime/pom.xml
+++ b/tosca-controlloop/runtime/pom.xml
@@ -32,10 +32,9 @@
<artifactId>controlloop-runtime</artifactId>
<name>${project.artifactId}</name>
- <description>Runtime server of the TOSCA Control Loop system</description>
<dependencies>
- <dependency>
+ <dependency>
<groupId>org.onap.policy.clamp.controlloop</groupId>
<artifactId>controlloop-common</artifactId>
<version>${project.version}</version>
@@ -45,10 +44,5 @@
<artifactId>controlloop-models</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
-</project>
+</project> \ No newline at end of file
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
index ab917b74e..88e8b1df9 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
@@ -65,26 +65,6 @@ public final class CommissioningHandler extends ControlLoopHandler {
}
@Override
- public void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher) {
- // No topic communication on this handler
- }
-
- @Override
- public void startAndRegisterPublishers(List<TopicSink> topicSinks) {
- // No topic communication on this handler
- }
-
- @Override
- public void stopAndUnregisterPublishers() {
- // No topic communication on this handler
- }
-
- @Override
- public void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher) {
- // No topic communication on this handler
- }
-
- @Override
public void startProviders() {
provider = new CommissioningProvider(getDatabaseProviderParameters());
}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
index 41d85726e..50f6787b9 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -40,6 +40,7 @@ import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
/**
@@ -190,4 +191,18 @@ public class CommissioningProvider implements Closeable {
return controlLoopElementList;
}
+
+ /**
+ * 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
+ */
+ public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException {
+ ToscaServiceTemplates serviceTemplates = new ToscaServiceTemplates();
+ serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
+ return serviceTemplates.getServiceTemplates().get(0);
+ }
}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
index cd6c08e30..18e1f7787 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
@@ -44,6 +44,7 @@ import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProv
import org.onap.policy.clamp.controlloop.runtime.main.rest.RestController;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.errors.concepts.ErrorResponse;
import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -131,7 +132,9 @@ public class CommissioningController extends RestController {
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Commissioning of the control loops failed", e);
- return createCommissioningErrorResponse(e, requestId);
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
}
@@ -201,7 +204,9 @@ public class CommissioningController extends RestController {
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Decommisssioning of control loop failed", e);
- return createCommissioningErrorResponse(e, requestId);
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
}
@@ -255,9 +260,9 @@ public class CommissioningController extends RestController {
// @formatter:on
public Response query(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@ApiParam(value = "Control Loop definition name", required = true)
- @QueryParam("name") String name,
+ @QueryParam("name") String name,
@ApiParam(value = "Control Loop definition version", required = true)
- @QueryParam("version") String version) {
+ @QueryParam("version") String version) {
try {
List<ToscaNodeTemplate> response = provider.getControlLoopDefinitions(name, version);
@@ -266,7 +271,9 @@ public class CommissioningController extends RestController {
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of control loop definitions failed", e);
- return createCommissioningErrorResponse(e, requestId);
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
}
@@ -319,33 +326,35 @@ public class CommissioningController extends RestController {
)
// @formatter:on
public Response queryElements(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true)
- @QueryParam("name") String name,
- @ApiParam(value = "Control Loop definition version", required = true)
- @QueryParam("version") String version) throws Exception {
+ @ApiParam(value = "Control Loop definition name", required = true)
+ @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true)
+ @QueryParam("version") String version) throws Exception {
try {
List<ToscaNodeTemplate> nodeTemplate = provider.getControlLoopDefinitions(name, version);
//Prevent ambiguous queries with multiple returns
if (nodeTemplate.size() > 1) {
- throw new Exception();
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails("Multiple ControlLoops are not supported");
+ return returnResponse(Response.Status.NOT_ACCEPTABLE, requestId, resp);
}
+
List<ToscaNodeTemplate> response = provider.getControlLoopElementDefinitions(nodeTemplate.get(0));
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
.build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of control loop element definitions failed", e);
- return createCommissioningErrorResponse(e, requestId);
+ CommissioningResponse resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
}
- private Response createCommissioningErrorResponse(ErrorResponseInfo e, UUID requestId) {
- CommissioningResponse resp = new CommissioningResponse();
- resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
- return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
+ private Response returnResponse(Response.Status status, UUID requestId, CommissioningResponse resp) {
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(status)),
requestId).entity(resp).build();
}
-
}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
index 6fd5f3225..eb72d9219 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
@@ -39,6 +39,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider
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;
@@ -140,19 +141,21 @@ public class ControlLoopInstantiationProvider implements Closeable {
*/
private BeanValidationResult validateControlLoops(ControlLoops controlLoops) throws PfModelException {
- BeanValidationResult validationResult = new BeanValidationResult("ControlLoops", controlLoops);
+ BeanValidationResult result = new BeanValidationResult("ControlLoops", controlLoops);
for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
+ BeanValidationResult subResult = new BeanValidationResult(
+ "entry " + controlLoop.getDefinition().getName(), controlLoop);
List<ToscaNodeTemplate> toscaNodeTemplates = commissioningProvider.getControlLoopDefinitions(
controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
if (toscaNodeTemplates.isEmpty()) {
- validationResult
+ subResult
.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
ValidationStatus.INVALID, "Commissioned control loop definition not FOUND"));
} else if (toscaNodeTemplates.size() > 1) {
- validationResult
+ subResult
.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
ValidationStatus.INVALID, "Commissioned control loop definition not VALID"));
} else {
@@ -167,12 +170,13 @@ public class ControlLoopInstantiationProvider implements Closeable {
.collect(Collectors.toMap(ToscaConceptIdentifier::getName, UnaryOperator.identity()));
// @formatter:on
- for (ControlLoopElement element : controlLoop.getElements()) {
- validationResult.addResult(validateDefinition(definitions, element.getDefinition()));
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ subResult.addResult(validateDefinition(definitions, element.getDefinition()));
}
}
+ result.addResult(subResult);
}
- return validationResult;
+ return result;
}
/**
@@ -183,15 +187,13 @@ public class ControlLoopInstantiationProvider implements Closeable {
* @result result the validation result
*/
private ValidationResult validateDefinition(Map<String, ToscaConceptIdentifier> definitions,
- ToscaConceptIdentifier definition) {
- BeanValidationResult result = new BeanValidationResult(definition.getName(), definition);
+ ToscaConceptIdentifier definition) {
+ BeanValidationResult 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");
- } else {
- result.setResult(ValidationStatus.CLEAN);
}
return (result.isClean() ? null : result);
}
@@ -264,6 +266,8 @@ public class ControlLoopInstantiationProvider implements Closeable {
controlLoopProvider.updateControlLoops(controlLoops);
}
+ SupervisionHandler supervisionHandler = SupervisionHandler.getInstance();
+ supervisionHandler.triggerControlLoopSupervision(command.getControlLoopIdentifierList());
InstantiationResponse response = new InstantiationResponse();
response.setAffectedControlLoops(command.getControlLoopIdentifierList());
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
index fd5288fda..d81e54ccf 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
@@ -21,13 +21,11 @@
package org.onap.policy.clamp.controlloop.runtime.instantiation;
import java.io.IOException;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.rest.CommissioningController;
import org.onap.policy.clamp.controlloop.runtime.instantiation.rest.InstantiationController;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
@@ -36,11 +34,9 @@ import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelRuntimeException;
/**
- * This class handles instantiation of control loop instances,
- * so only one object of this type should be built at a time.
+ * This class handles instantiation of control loop instances.
*
- * </p>
- * It is effectively a singleton that is started at system start
+ * <p/>It is effectively a singleton that is started at system start
*/
public final class InstantiationHandler extends ControlLoopHandler {
@@ -71,26 +67,6 @@ public final class InstantiationHandler extends ControlLoopHandler {
}
@Override
- public void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher) {
- // No topic communication on this handler
- }
-
- @Override
- public void startAndRegisterPublishers(List<TopicSink> topicSinks) {
- // No topic communication on this handler
- }
-
- @Override
- public void stopAndUnregisterPublishers() {
- // No topic communication on this handler
- }
-
- @Override
- public void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher) {
- // No topic communication on this handler
- }
-
- @Override
public void startProviders() {
controlLoopInstantiationProvider = new ControlLoopInstantiationProvider(getDatabaseProviderParameters());
}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
index 807da5d68..7581aaf74 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
@@ -412,5 +412,5 @@ public class InstantiationController extends RestController {
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).entity(resp).build();
}
-
}
+
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java
index a7f5ff34d..a463ad171 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java
@@ -24,7 +24,7 @@ import java.io.File;
import javax.ws.rs.core.Response;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
import org.onap.policy.clamp.controlloop.runtime.main.startstop.ClRuntimeCommandLineArguments;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -66,7 +66,7 @@ public class ClRuntimeParameterHandler {
}
// validate the parameters
- final GroupValidationResult validationResult = clRuntimeParameterGroup.validate();
+ final ValidationResult validationResult = clRuntimeParameterGroup.validate();
if (!validationResult.isValid()) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, "validation error(s) on parameters from \""
+ arguments.getConfigurationFilePath() + "\"\n" + validationResult.getResult());
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
index f70e7d590..2af5be534 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
@@ -51,3 +51,4 @@ public class ParticipantUpdateParameters extends ParameterGroupImpl {
super(ParticipantUpdateParameters.class.getSimpleName());
}
}
+
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
index 5959586da..a4238a9c4 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
@@ -32,6 +32,7 @@ import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationHand
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.main.rest.ControlLoopAafFilter;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringHandler;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
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;
@@ -65,6 +66,7 @@ public class ClRuntimeActivator extends ServiceManagerContainer {
* @param clRuntimeParameterGroup the parameters for the control loop runtime service
*/
public ClRuntimeActivator(final ClRuntimeParameterGroup clRuntimeParameterGroup) {
+
if (clRuntimeParameterGroup == null || !clRuntimeParameterGroup.isValid()) {
throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR, "ParameterGroup not valid");
}
@@ -86,28 +88,38 @@ public class ClRuntimeActivator extends ServiceManagerContainer {
final AtomicReference<ControlLoopHandler> commissioningHandler = new AtomicReference<>();
final AtomicReference<ControlLoopHandler> instantiationHandler = new AtomicReference<>();
+ final AtomicReference<ControlLoopHandler> supervisionHandler = new AtomicReference<>();
final AtomicReference<ControlLoopHandler> monitoringHandler = new AtomicReference<>();
-
final AtomicReference<RestServer> restServer = new AtomicReference<>();
+
// @formatter:off
addAction("Control loop runtime parameters",
- () -> ParameterService.register(clRuntimeParameterGroup),
- () -> ParameterService.deregister(clRuntimeParameterGroup.getName()));
+ () -> ParameterService.register(clRuntimeParameterGroup),
+ () -> ParameterService.deregister(clRuntimeParameterGroup.getName()));
+
addAction("Topic endpoint management",
- () -> TopicEndpointManager.getManager().start(),
- () -> TopicEndpointManager.getManager().shutdown());
+ () -> TopicEndpointManager.getManager().start(),
+ () -> TopicEndpointManager.getManager().shutdown());
+
addAction("Commissioning Handler",
() -> commissioningHandler.set(new CommissioningHandler(clRuntimeParameterGroup)),
() -> commissioningHandler.get().close());
+
addAction("Instantiation Handler",
- () -> instantiationHandler.set(new InstantiationHandler(clRuntimeParameterGroup)),
- () -> instantiationHandler.get().close());
+ () -> instantiationHandler.set(new InstantiationHandler(clRuntimeParameterGroup)),
+ () -> instantiationHandler.get().close());
+
+ addAction("Supervision Handler",
+ () -> supervisionHandler.set(new SupervisionHandler(clRuntimeParameterGroup)),
+ () -> supervisionHandler.get().close());
+
addAction("Monitoring Handler",
() -> monitoringHandler.set(new MonitoringHandler(clRuntimeParameterGroup)),
() -> monitoringHandler.get().close());
addHandlerActions("Commissioning", commissioningHandler);
addHandlerActions("Instantiation", instantiationHandler);
+ addHandlerActions("Supervision", supervisionHandler);
addHandlerActions("Monitoring", monitoringHandler);
addAction("Topic Message Dispatcher", this::registerMsgDispatcher, this::unregisterMsgDispatcher);
@@ -115,34 +127,34 @@ public class ClRuntimeActivator extends ServiceManagerContainer {
clRuntimeParameterGroup.getRestServerParameters().setName(clRuntimeParameterGroup.getName());
addAction("REST server",
- () -> {
- Set<Class<?>> providerClasses = new HashSet<>();
- providerClasses.addAll(commissioningHandler.get().getProviderClasses());
- providerClasses.addAll(instantiationHandler.get().getProviderClasses());
- providerClasses.addAll(monitoringHandler.get().getProviderClasses());
-
- RestServer server = new RestServer(clRuntimeParameterGroup.getRestServerParameters(),
- ControlLoopAafFilter.class,
- providerClasses.toArray(new Class<?>[providerClasses.size()]));
- restServer.set(server);
- restServer.get().start();
- },
- () -> restServer.get().stop());
+ () -> {
+ Set<Class<?>> providerClasses = new HashSet<>();
+ providerClasses.addAll(commissioningHandler.get().getProviderClasses());
+ providerClasses.addAll(instantiationHandler.get().getProviderClasses());
+ providerClasses.addAll(supervisionHandler.get().getProviderClasses());
+ providerClasses.addAll(monitoringHandler.get().getProviderClasses());
+
+ RestServer server = new RestServer(clRuntimeParameterGroup.getRestServerParameters(),
+ ControlLoopAafFilter.class,
+ providerClasses.toArray(new Class<?>[providerClasses.size()]));
+
+ restServer.set(server);
+ restServer.get().start();
+ },
+ () -> restServer.get().stop());
// @formatter:on
}
private void addHandlerActions(final String name, final AtomicReference<ControlLoopHandler> handler) {
addAction(name + " Providers",
- () -> handler.get().startProviders(),
- () -> handler.get().stopProviders());
-
+ () -> handler.get().startProviders(),
+ () -> handler.get().stopProviders());
addAction(name + " Listeners",
- () -> handler.get().startAndRegisterListeners(msgDispatcher),
- () -> handler.get().stopAndUnregisterListeners(msgDispatcher));
-
+ () -> handler.get().startAndRegisterListeners(msgDispatcher),
+ () -> handler.get().stopAndUnregisterListeners(msgDispatcher));
addAction(name + " Publishers",
- () -> handler.get().startAndRegisterPublishers(topicSinks),
- () -> handler.get().stopAndUnregisterPublishers());
+ () -> handler.get().startAndRegisterPublishers(topicSinks),
+ () -> handler.get().stopAndUnregisterPublishers());
}
/**
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
index fa25b6ddb..f36bb858b 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
@@ -26,55 +26,58 @@ import java.io.StringWriter;
import java.net.URL;
import java.util.Arrays;
import javax.ws.rs.core.Response;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments;
import org.onap.policy.common.utils.resources.ResourceUtils;
-
/**
* This class reads and handles command line parameters for the control loop runtime service.
- *
*/
public class ClRuntimeCommandLineArguments {
private static final String FILE_MESSAGE_PREAMBLE = " file \"";
private static final int HELP_LINE_LENGTH = 120;
private final Options options;
+ private final CommonCommandLineArguments commonCommandLineArguments;
+
+ @Getter()
+ @Setter()
private String configurationFilePath = null;
/**
* Construct the options for the control loop runtime component.
*/
public ClRuntimeCommandLineArguments() {
- //@formatter:off
options = new Options();
- options.addOption(Option.builder("h")
- .longOpt("help")
- .desc("outputs the usage of this command")
- .required(false)
- .type(Boolean.class)
- .build());
- options.addOption(Option.builder("v")
- .longOpt("version")
- .desc("outputs the version of control loop runtime")
- .required(false)
- .type(Boolean.class)
- .build());
- options.addOption(Option.builder("c")
- .longOpt("config-file")
- .desc("the full path to the configuration file to use, "
- + "the configuration file must be a Json file containing the control loop runtime parameters")
- .hasArg()
- .argName("CONFIG_FILE")
- .required(false)
- .type(String.class)
- .build());
- //@formatter:on
+ commonCommandLineArguments = new CommonCommandLineArguments(options);
+ }
+
+ /**
+ * Construct the options for the CLI editor and parse in the given arguments.
+ *
+ * @param args The command line arguments
+ */
+ public ClRuntimeCommandLineArguments(final String[] args) {
+ // Set up the options with the default constructor
+ this();
+
+ // Parse the arguments
+ try {
+ parse(args);
+ } catch (final ControlLoopException e) {
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
+ "parse error on control loop runtime parameters", e);
+ }
}
/**
@@ -87,13 +90,12 @@ public class ClRuntimeCommandLineArguments {
public String parse(final String[] args) throws ControlLoopException {
// Clear all our arguments
setConfigurationFilePath(null);
-
CommandLine commandLine = null;
try {
commandLine = new DefaultParser().parse(options, args);
} catch (final ParseException e) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- "invalid command line arguments specified", e);
+ "invalid command line arguments specified : " + e.getMessage());
}
// Arguments left over after Commons CLI does its stuff
@@ -104,16 +106,12 @@ public class ClRuntimeCommandLineArguments {
"too many command line arguments specified : " + Arrays.toString(args));
}
- if (remainingArgs.length == 1) {
- configurationFilePath = remainingArgs[0];
- }
-
if (commandLine.hasOption('h')) {
- return help(Main.class.getName());
+ return commonCommandLineArguments.help(Main.class.getName(), options);
}
if (commandLine.hasOption('v')) {
- return version();
+ return commonCommandLineArguments.version();
}
if (commandLine.hasOption('c')) {
@@ -129,42 +127,7 @@ public class ClRuntimeCommandLineArguments {
* @throws ControlLoopException on command argument validation errors
*/
public void validate() throws ControlLoopException {
- validateReadableFile("control loop runtime configuration", configurationFilePath);
- }
-
- /**
- * Print version information for control loop runtime.
- *
- * @return the version string
- */
- public String version() {
- return ResourceUtils.getResourceAsString("version.txt");
- }
-
- /**
- * Print help information for control loop runtime.
- *
- * @param mainClassName the main class name
- * @return the help string
- */
- public String help(final String mainClassName) {
- final HelpFormatter helpFormatter = new HelpFormatter();
- final StringWriter stringWriter = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(stringWriter);
-
- helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0,
- 0, "");
-
- return stringWriter.toString();
- }
-
- /**
- * Gets the configuration file path.
- *
- * @return the configuration file path
- */
- public String getConfigurationFilePath() {
- return configurationFilePath;
+ commonCommandLineArguments.validate(configurationFilePath);
}
/**
@@ -185,39 +148,4 @@ public class ClRuntimeCommandLineArguments {
this.configurationFilePath = configurationFilePath;
}
-
- /**
- * Validate readable file.
- *
- * @param fileTag the file tag
- * @param fileName the file name
- * @throws ControlLoopException on the file name passed as a parameter
- */
- private void validateReadableFile(final String fileTag, final String fileName) throws ControlLoopException {
- if (fileName == null || fileName.length() == 0) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- fileTag + " file was not specified as an argument");
- }
-
- // The file name refers to a resource on the local file system
- final URL fileUrl = ResourceUtils.getUrl4Resource(fileName);
- if (fileUrl == null) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
- }
-
- final File theFile = new File(fileUrl.getPath());
- if (!theFile.exists()) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
- }
- if (!theFile.isFile()) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file");
- }
- if (!theFile.canRead()) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is ureadable");
- }
- }
}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
index 04f458e7d..a7ad9180a 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
@@ -69,26 +69,6 @@ public class MonitoringHandler extends ControlLoopHandler {
}
@Override
- public void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher) {
- // No topic communication on this handler
- }
-
- @Override
- public void startAndRegisterPublishers(List<TopicSink> topicSinks) {
- // No topic communication on this handler
- }
-
- @Override
- public void stopAndUnregisterPublishers() {
- // No topic communication on this handler
- }
-
- @Override
- public void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher) {
- // No topic communication on this handler
- }
-
- @Override
public void startProviders() {
monitoringProvider = new MonitoringProvider(getDatabaseProviderParameters());
}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
index e46e66501..193f8d557 100644
--- a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
@@ -206,7 +206,7 @@ public class MonitoringProvider implements Closeable {
ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name,
version));
if (controlLoop != null) {
- clElements.addAll(controlLoop.getElements());
+ clElements.addAll(controlLoop.getElements().values());
//Collect control loop element statistics for each cl element.
for (ControlLoopElement clElement : clElements) {
clElementStats.addAll(fetchFilteredClElementStatistics(clElement.getParticipantId().getName(),
@@ -235,7 +235,7 @@ public class MonitoringProvider implements Closeable {
List<ToscaConceptIdentifier> participantIds = new ArrayList<>();
ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
if (controlLoop != null) {
- for (ControlLoopElement clElement : controlLoop.getElements()) {
+ for (ControlLoopElement clElement : controlLoop.getElements().values()) {
participantIds.add(clElement.getParticipantId());
}
}
@@ -256,7 +256,7 @@ public class MonitoringProvider implements Closeable {
Map<String, ToscaConceptIdentifier> clElementId = new HashMap<>();
ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
if (controlLoop != null) {
- for (ControlLoopElement clElement : controlLoop.getElements()) {
+ for (ControlLoopElement clElement : controlLoop.getElements().values()) {
clElementId.put(clElement.getId().toString(), clElement.getParticipantId());
}
}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
new file mode 100644
index 000000000..63bff00fc
--- /dev/null
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
@@ -0,0 +1,450 @@
+/*-
+ * ============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.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import org.apache.commons.collections4.CollectionUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
+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.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
+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.commissioning.CommissioningHandler;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringHandler;
+import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantControlLoopStateChangePublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantControlLoopUpdatePublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStateChangePublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusListener;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+import org.onap.policy.common.utils.services.Registry;
+import org.onap.policy.common.utils.services.ServiceManager;
+import org.onap.policy.common.utils.services.ServiceManagerException;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 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.
+ */
+public class SupervisionHandler extends ControlLoopHandler {
+ 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 ControlLoopProvider controlLoopProvider;
+ private ParticipantProvider participantProvider;
+ private CommissioningProvider commissioningProvider;
+ private MonitoringProvider monitoringProvider;
+
+ // Publishers for participant communication
+ private ParticipantStateChangePublisher stateChangePublisher;
+ private ParticipantControlLoopUpdatePublisher controlLoopUpdatePublisher;
+ private ParticipantControlLoopStateChangePublisher controlLoopStateChangePublisher;
+
+ // Database scanner
+ private SupervisionScanner scanner;
+
+ /**
+ * Used to manage the services.
+ */
+ private ServiceManager manager;
+ private ServiceManager publisherManager;
+
+ /**
+ * Gets the SupervisionHandler.
+ *
+ * @return SupervisionHandler
+ */
+ public static SupervisionHandler getInstance() {
+ return Registry.get(SupervisionHandler.class.getName());
+ }
+
+ /**
+ * Create a handler.
+ *
+ * @param clRuntimeParameterGroup the parameters for the control loop runtime
+ */
+ public SupervisionHandler(ClRuntimeParameterGroup clRuntimeParameterGroup) {
+ super(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ // @formatter:off
+ this.manager = new ServiceManager()
+ .addAction("ControlLoop Provider",
+ () -> controlLoopProvider = new ControlLoopProvider(getDatabaseProviderParameters()),
+ () -> controlLoopProvider = null)
+ .addAction("Participant Provider",
+ () -> participantProvider = new ParticipantProvider(getDatabaseProviderParameters()),
+ () -> participantProvider = null);
+ // @formatter:on
+ }
+
+ /**
+ * 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 {
+ ControlLoop controlLoop = controlLoopProvider.getControlLoop(controlLoopId);
+
+ superviseControlLoop(controlLoop);
+
+ controlLoopProvider.updateControlLoop(controlLoop);
+ } catch (PfModelException pfme) {
+ throw new ControlLoopException(pfme.getErrorResponse().getResponseCode(), pfme.getMessage(), pfme);
+ }
+ }
+ }
+
+ @Override
+ public void startAndRegisterListeners(MessageTypeDispatcher msgDispatcher) {
+ msgDispatcher.register(ParticipantMessageType.PARTICIPANT_STATUS.name(), new ParticipantStatusListener());
+ }
+
+ @Override
+ public void startAndRegisterPublishers(List<TopicSink> topicSinks) {
+ // TODO: Use a parameter for the timeout
+ // @formatter:off
+ this.publisherManager = new ServiceManager()
+ .addAction("Supervision scanner",
+ () -> scanner = new SupervisionScanner(controlLoopProvider, 10000),
+ () -> scanner = null)
+ .addAction("ControlLoopUpdate publisher",
+ () -> controlLoopUpdatePublisher = new ParticipantControlLoopUpdatePublisher(topicSinks, -1),
+ () -> controlLoopUpdatePublisher.terminate())
+ .addAction("StateChange Publisher",
+ () -> stateChangePublisher = new ParticipantStateChangePublisher(topicSinks, 10000),
+ () -> stateChangePublisher.terminate())
+ .addAction("ControlLoopStateChange Publisher",
+ () -> controlLoopStateChangePublisher =
+ new ParticipantControlLoopStateChangePublisher(topicSinks, -1),
+ () -> controlLoopStateChangePublisher.terminate());
+ // @formatter:on
+ try {
+ publisherManager.start();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler start of publishers or scanner failed", exp);
+ }
+ }
+
+ @Override
+ public void stopAndUnregisterPublishers() {
+ try {
+ publisherManager.stop();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler stop of publishers or scanner failed", exp);
+ }
+ }
+
+ @Override
+ public void stopAndUnregisterListeners(MessageTypeDispatcher msgDispatcher) {
+ msgDispatcher.unregister(ParticipantMessageType.PARTICIPANT_STATUS.name());
+ }
+
+ /**
+ * Handle a ParticipantStatus message from a participant.
+ *
+ * @param participantStatusMessage the ParticipantStatus message received from a participant
+ */
+ public void handleParticipantStatusMessage(ParticipantStatus participantStatusMessage) {
+ LOGGER.debug("Participant Status received {}", participantStatusMessage);
+
+ try {
+ superviseParticipant(participantStatusMessage);
+ } catch (PfModelException | ControlLoopException svExc) {
+ LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
+ return;
+ }
+
+ try {
+ superviseControlLoops(participantStatusMessage);
+ } catch (PfModelException | ControlLoopException svExc) {
+ LOGGER.warn("error supervising participant {}", participantStatusMessage.getParticipantId(), svExc);
+ }
+ }
+
+ /**
+ * Supervise a control loop, performing whatever actions need to be performed on the control loop.
+ *
+ * @param controlLoop the control loop to supervises
+ * @throws ControlLoopException on supervision errors
+ */
+ private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
+ switch (controlLoop.getOrderedState()) {
+ case UNINITIALISED:
+ superviseControlLoopUninitialization(controlLoop);
+ break;
+
+ case PASSIVE:
+ superviseControlLoopPassivation(controlLoop);
+ break;
+
+ case RUNNING:
+ superviseControlLoopActivation(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ "A control loop cannot be commanded to go into state " + controlLoop.getOrderedState().name());
+ }
+ }
+
+ /**
+ * Supervise a control loop uninitialisation, performing whatever actions need to be performed on the control loop,
+ * control loop ordered state is UNINITIALIZED.
+ *
+ * @param controlLoop the control loop to supervises
+ * @throws ControlLoopException on supervision errors
+ */
+ private void superviseControlLoopUninitialization(ControlLoop controlLoop) throws ControlLoopException {
+ switch (controlLoop.getState()) {
+ case UNINITIALISED:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+
+ case UNINITIALISED2PASSIVE:
+ case PASSIVE:
+ controlLoop.setState(ControlLoopState.PASSIVE2UNINITIALISED);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ case PASSIVE2UNINITIALISED:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void superviseControlLoopPassivation(ControlLoop controlLoop)
+ throws ControlLoopException, PfModelException {
+ switch (controlLoop.getState()) {
+ case PASSIVE:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+ case UNINITIALISED:
+ controlLoop.setState(ControlLoopState.UNINITIALISED2PASSIVE);
+ sendControlLoopUpdate(controlLoop);
+ break;
+
+ case UNINITIALISED2PASSIVE:
+ case RUNNING2PASSIVE:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ case RUNNING:
+ controlLoop.setState(ControlLoopState.RUNNING2PASSIVE);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void superviseControlLoopActivation(ControlLoop controlLoop) throws ControlLoopException {
+ switch (controlLoop.getState()) {
+ case RUNNING:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE,
+ CONTROL_LOOP_IS_ALREADY_IN_STATE + controlLoop.getState().name());
+ break;
+
+ case PASSIVE2RUNNING:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_IS_ALREADY_IN_STATE
+ + controlLoop.getState().name() + AND_TRANSITIONING_TO_STATE + controlLoop.getOrderedState());
+ break;
+
+ case PASSIVE:
+ controlLoop.setState(ControlLoopState.PASSIVE2RUNNING);
+ sendControlLoopStateChange(controlLoop);
+ break;
+
+ default:
+ exceptionOccured(Response.Status.NOT_ACCEPTABLE, CONTROL_LOOP_CANNOT_TRANSITION_FROM_STATE
+ + controlLoop.getState().name() + TO_STATE + controlLoop.getOrderedState());
+ break;
+ }
+ }
+
+ private void sendControlLoopUpdate(ControlLoop controlLoop) throws PfModelException {
+ ParticipantControlLoopUpdate pclu = new ParticipantControlLoopUpdate();
+ pclu.setControlLoopId(controlLoop.getKey().asIdentifier());
+ pclu.setControlLoop(controlLoop);
+ // TODO: We should look up the correct TOSCA node template here for the control loop
+ // Tiny hack implemented to return the tosca service template entry from the database and be passed onto dmaap
+ commissioningProvider = CommissioningHandler.getInstance().getProvider();
+ pclu.setControlLoopDefinition(commissioningProvider.getToscaServiceTemplate(null, null));
+ controlLoopUpdatePublisher.send(pclu);
+ }
+
+ private void sendControlLoopStateChange(ControlLoop controlLoop) {
+ ParticipantControlLoopStateChange clsc = new ParticipantControlLoopStateChange();
+ clsc.setControlLoopId(controlLoop.getKey().asIdentifier());
+ clsc.setMessageId(UUID.randomUUID());
+ clsc.setOrderedState(controlLoop.getOrderedState());
+
+ controlLoopStateChangePublisher.send(clsc);
+ }
+
+ private void superviseParticipant(ParticipantStatus participantStatusMessage)
+ throws PfModelException, ControlLoopException {
+ if (participantStatusMessage.getParticipantId() == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "Participant ID on PARTICIPANT_STATUS message is null");
+ }
+
+ List<Participant> participantList =
+ participantProvider.getParticipants(participantStatusMessage.getParticipantId().getName(),
+ participantStatusMessage.getParticipantId().getVersion());
+
+ if (CollectionUtils.isEmpty(participantList)) {
+ Participant participant = new Participant();
+ participant.setName(participantStatusMessage.getParticipantId().getName());
+ participant.setVersion(participantStatusMessage.getParticipantId().getVersion());
+ participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
+ participant.setParticipantState(participantStatusMessage.getState());
+ participant.setHealthStatus(participantStatusMessage.getHealthStatus());
+
+ participantList.add(participant);
+ participantProvider.createParticipants(participantList);
+ } else {
+ for (Participant participant : participantList) {
+ participant.setParticipantState(participantStatusMessage.getState());
+ participant.setHealthStatus(participantStatusMessage.getHealthStatus());
+ }
+ participantProvider.updateParticipants(participantList);
+ }
+
+ monitoringProvider = MonitoringHandler.getInstance().getMonitoringProvider();
+ monitoringProvider.createParticipantStatistics(
+ List.of(participantStatusMessage.getParticipantStatistics()));
+ }
+
+ private void superviseControlLoops(ParticipantStatus participantStatusMessage)
+ throws PfModelException, ControlLoopException {
+ if (CollectionUtils.isEmpty(participantStatusMessage.getControlLoops().getControlLoopList())) {
+ return;
+ }
+
+ for (ControlLoop controlLoop : participantStatusMessage.getControlLoops().getControlLoopList()) {
+ if (controlLoop == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS message references unknown control loop: " + controlLoop);
+ }
+
+ ControlLoop dbControlLoop = controlLoopProvider
+ .getControlLoop(new ToscaConceptIdentifier(controlLoop.getName(), controlLoop.getVersion()));
+ if (dbControlLoop == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS control loop not found in database: " + controlLoop);
+ }
+
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ ControlLoopElement dbElement = dbControlLoop.getElements().get(element.getId());
+
+ if (dbElement == null) {
+ exceptionOccured(Response.Status.NOT_FOUND,
+ "PARTICIPANT_STATUS message references unknown control loop element: " + element);
+ }
+
+ // Replace element entry in the database
+ dbControlLoop.getElements().put(element.getId(), element);
+ }
+ controlLoopProvider.updateControlLoop(dbControlLoop);
+ }
+
+ monitoringProvider = MonitoringHandler.getInstance().getMonitoringProvider();
+ for (ControlLoop controlLoop : participantStatusMessage.getControlLoops().getControlLoopList()) {
+ monitoringProvider.createClElementStatistics(controlLoop.getControlLoopElementStatisticsList(controlLoop));
+ }
+ }
+
+ @Override
+ public void startProviders() {
+ try {
+ manager.start();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler start of providers failed", exp);
+ }
+ }
+
+ @Override
+ public void stopProviders() {
+ try {
+ manager.stop();
+ } catch (final ServiceManagerException exp) {
+ throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
+ "Supervision handler stop of providers failed", exp);
+ }
+ }
+
+ private void exceptionOccured(Response.Status status, String reason) throws ControlLoopException {
+ throw new ControlLoopException(status, reason);
+ }
+}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
new file mode 100644
index 000000000..0ccfddff3
--- /dev/null
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision;
+
+import java.io.Closeable;
+import java.util.Collection;
+import java.util.List;
+import java.util.TimerTask;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.models.base.PfModelException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to scan the control loops in the database and check if they are in the correct state.
+ */
+public class SupervisionScanner implements Runnable, Closeable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class);
+
+ private ControlLoopProvider controlLoopProvider;
+ private ScheduledExecutorService timerPool;
+
+ /**
+ * Constructor for instantiating SupervisionScanner.
+ *
+ * @param controlLoopProvider the provider to use to read control loops from the database
+ * @param interval time interval to perform scans
+ */
+ public SupervisionScanner(final ControlLoopProvider controlLoopProvider, final long interval) {
+ this.controlLoopProvider = controlLoopProvider;
+
+ // Kick off the timer
+ timerPool = makeTimerPool();
+ timerPool.scheduleAtFixedRate(this, 0, interval, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public void run() {
+ LOGGER.debug("Scanning control loops in the database . . .");
+
+ try {
+ for (ControlLoop controlLoop : controlLoopProvider.getControlLoops(null, null)) {
+ scanControlLoop(controlLoop);
+ }
+ } catch (PfModelException pfme) {
+ LOGGER.warn("error reading control loops from database", pfme);
+ }
+
+ LOGGER.debug("Control loop scan complete . . .");
+ }
+
+ @Override
+ public void close() {
+ timerPool.shutdown();
+ }
+
+ private void scanControlLoop(final ControlLoop controlLoop) throws PfModelException {
+ LOGGER.debug("scanning control loop {} . . .", controlLoop.getKey().asIdentifier());
+
+ if (controlLoop.getState().equals(controlLoop.getOrderedState().asState())) {
+ LOGGER.debug("control loop {} scanned, OK", controlLoop.getKey().asIdentifier());
+ return;
+ }
+
+ for (ControlLoopElement element : controlLoop.getElements().values()) {
+ if (!element.getState().equals(element.getOrderedState().asState())) {
+ LOGGER.debug("control loop scan: transitioning from state {} to {}", controlLoop.getState(),
+ controlLoop.getOrderedState());
+ return;
+ }
+ }
+
+ LOGGER.debug("control loop scan: transition from state {} to {} completed", controlLoop.getState(),
+ controlLoop.getOrderedState());
+
+ controlLoop.setState(controlLoop.getOrderedState().asState());
+ controlLoopProvider.updateControlLoop(controlLoop);
+ }
+
+ /**
+ * Makes a new timer pool.
+ *
+ * @return a new timer pool
+ */
+ protected ScheduledExecutorService makeTimerPool() {
+ return Executors.newScheduledThreadPool(1);
+ }
+}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java
new file mode 100644
index 000000000..c9c8ab851
--- /dev/null
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopStateChangePublisher.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantControlLoopStateChangePublisher messages to participants on DMaaP.
+ */
+public class ParticipantControlLoopStateChangePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantControlLoopStateChangePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantControlLoopStateChangePublisherPublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantControlLoopStateChangePublisher messages
+ */
+ public ParticipantControlLoopStateChangePublisher(final List<TopicSink> topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // This is a user initiated message and doesn't need a timer.
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ // This is a user initiated message and doesn't need a timer.
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantControlLoopStateChangePublisher status message to participants on demand.
+ *
+ * @param controlLoopStateChange the ParticipantControlLoopStateChangePublisher message
+ */
+ public void send(final ParticipantControlLoopStateChange controlLoopStateChange) {
+ topicSinkClient.send(controlLoopStateChange);
+ LOGGER.debug("Sent ParticipantControlLoopStateChange to Participants - {}", controlLoopStateChange);
+ }
+}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java
new file mode 100644
index 000000000..3c5d230c5
--- /dev/null
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantControlLoopUpdatePublisher.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantControlLoopUpdate messages to participants on DMaaP.
+ */
+public class ParticipantControlLoopUpdatePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantControlLoopUpdatePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantUpdatePublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantControlLoopUpdate messages
+ */
+ public ParticipantControlLoopUpdatePublisher(final List<TopicSink> topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // This is a user initiated message and doesn't need a timer.
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ // This is a user initiated message and doesn't need a timer.
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantControlLoopUpdate status message to participants on demand.
+ *
+ * @param participantControlLoopUpdate the ParticipantControlLoopUpdate message
+ */
+ public void send(final ParticipantControlLoopUpdate participantControlLoopUpdate) {
+ topicSinkClient.send(participantControlLoopUpdate);
+ LOGGER.debug("Sent ParticipantControlLoopUpdate to Participants - {}", participantControlLoopUpdate);
+ }
+}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java
new file mode 100644
index 000000000..099039115
--- /dev/null
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStateChangePublisher.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import java.util.List;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStateChange;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to send ParticipantStateChange messages to participants on DMaaP.
+ */
+public class ParticipantStateChangePublisher {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStateChangePublisher.class);
+
+ private TopicSinkClient topicSinkClient;
+
+ /**
+ * Constructor for instantiating ParticipantStateChangePublisher.
+ *
+ * @param topicSinks the topic sinks
+ * @param interval time interval to send ParticipantStateChange messages
+ */
+ public ParticipantStateChangePublisher(final List<TopicSink> topicSinks, final long interval) {
+ // TODO: Should not be dependent on the order of topic sinks in the config
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ }
+
+ /**
+ * Terminates the current timer.
+ */
+ public void terminate() {
+ // Nothing to terminate, this publisher does not have a timer
+ }
+
+ /**
+ * Get the current time interval used by the timer task.
+ *
+ * @return interval the current time interval
+ */
+ public long getInterval() {
+ return -1;
+ }
+
+ /**
+ * Method to send ParticipantStateChange status message to participants on demand.
+ *
+ * @param participantStateChange the ParticipantStateChange message
+ */
+ public void send(final ParticipantStateChange participantStateChange) {
+ topicSinkClient.send(participantStateChange);
+ LOGGER.debug("Sent ParticipantStateChange to Participants - {}", participantStateChange);
+ }
+}
diff --git a/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
new file mode 100644
index 000000000..a05f4aa20
--- /dev/null
+++ b/tosca-controlloop/runtime/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.onap.policy.common.utils.services.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Listener for ParticipantStatus messages sent by participants.
+ */
+public class ParticipantStatusListener extends ScoListener<ParticipantStatus> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantStatusListener.class);
+
+ private final SupervisionHandler supervisionHandler = Registry.get(SupervisionHandler.class.getName());
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantStatusListener() {
+ super(ParticipantStatus.class);
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantStatus participantStatusMessage) {
+ LOGGER.debug("ParticipantStatus message received from participant - {}", participantStatusMessage);
+ supervisionHandler.handleParticipantStatusMessage(participantStatusMessage);
+ }
+}
diff --git a/tosca-controlloop/runtime/src/main/resources/META-INF/persistence.xml b/tosca-controlloop/runtime/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 000000000..e5d2cab11
--- /dev/null
+++ b/tosca-controlloop/runtime/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="CommissioningMariaDb" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
+ <persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+ <properties>
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+</persistence>
+
diff --git a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
index 97599cd64..956b5e911 100644
--- a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
+++ b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
@@ -43,7 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public class CommissioningProviderTest {
private static final String TOSCA_SERVICE_TEMPLATE_YAML =
- "src/test/resources/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
private static final String TEMPLATE_IS_NULL = ".*serviceTemplate is marked non-null but is null";
private static final Coder CODER = new StandardCoder();
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
@@ -149,6 +149,9 @@ public class CommissioningProviderTest {
.fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML),
ToscaServiceTemplate.class);
+ listOfTemplates = provider.getControlLoopDefinitions(null, null);
+ assertThat(listOfTemplates).isEmpty();
+
provider.createControlLoopDefinitions(serviceTemplate);
listOfTemplates = provider.getControlLoopDefinitions(null, null);
assertThat(listOfTemplates).hasSize(2);
@@ -171,6 +174,8 @@ public class CommissioningProviderTest {
.fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML),
ToscaServiceTemplate.class);
+ provider.getControlLoopDefinitions(null, null);
+
provider.createControlLoopDefinitions(serviceTemplate);
List<ToscaNodeTemplate> controlLoopDefinitionList = provider.getControlLoopDefinitions(
"org.onap.domain.pmsh.PMSHControlLoopDefinition", "1.2.3");
diff --git a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
index fa146635d..4dbb3ea02 100644
--- a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
+++ b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
@@ -44,7 +44,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public class CommissioningControllerTest extends CommonRestController {
private static final String TOSCA_SERVICE_TEMPLATE_YAML =
- "src/test/resources/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
private static final String COMMISSIONING_ENDPOINT = "commission";
private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
@@ -59,7 +59,7 @@ public class CommissioningControllerTest extends CommonRestController {
CommonRestController.setUpBeforeClass("CommissioningApi");
serviceTemplate = yamlTranslator.fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML),
- ToscaServiceTemplate.class);
+ ToscaServiceTemplate.class);
}
@AfterClass
@@ -150,7 +150,7 @@ public class CommissioningControllerTest extends CommonRestController {
//Call get elements with no info
Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "/elements");
Response resp = invocationBuilder.buildGet().invoke();
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), resp.getStatus());
+ assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), resp.getStatus());
}
@Test
diff --git a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
index 0ec8fe3e8..ccc54b93f 100644
--- a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
+++ b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
@@ -25,16 +25,21 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
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.messages.rest.instantiation.InstantiationCommand;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
+import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningHandler;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -51,27 +56,32 @@ public class ControlLoopInstantiationProviderTest {
private static final String CL_INSTANTIATION_CHANGE_STATE_JSON =
"src/test/resources/rest/controlloops/PassiveCommand.json";
private static final String CL_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON =
- "src/test/resources/rest/controlloops/ControlLoopsElementsNotFound.json";
+ "src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json";
private static final String CL_INSTANTIATION_CONTROLLOOP_DEFINITION_NOT_FOUND_JSON =
"src/test/resources/rest/controlloops/ControlLoopsNotFound.json";
- private static final String TOSCA_TEMPLATE_YAML = "examples/controlloop/PMSubscriptionHandling.yaml";
-
+ private static final String TOSCA_TEMPLATE_YAML =
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
private static final String CONTROL_LOOP_NOT_FOUND = "Control Loop not found";
private static final String DELETE_BAD_REQUEST = "Control Loop State is still %s";
private static final String ORDERED_STATE_INVALID = "ordered state invalid or not specified on command";
-
private static final String CONTROLLOOP_ELEMENT_NAME_NOT_FOUND =
"\"ControlLoops\" INVALID, item has status INVALID\n"
- + " \"org.onap.domain.pmsh.NotExistFirst\" INVALID, Not FOUND\n"
- + " \"org.onap.domain.pmsh.NotExistSecond\" INVALID, Not FOUND\n";
+ + " \"entry org.onap.domain.pmsh.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n"
+ + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not FOUND\n"
+ + " \"entry org.onap.domain.pmsh.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n"
+ + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not FOUND\n";
private static final String CONTROLLOOP_DEFINITION_NOT_FOUND = "\"ControlLoops\" INVALID, item has status INVALID\n"
- + " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID,"
+ + " \"entry org.onap.domain.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n"
+ + " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID,"
+ " Commissioned control loop definition not FOUND\n"
- + " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID,"
+ + " \"entry org.onap.domain.PMSHControlLoopDefinition\" INVALID, item has status INVALID\n"
+ + " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID,"
+ " Commissioned control loop definition not FOUND\n";
private static PolicyModelsProviderParameters databaseProviderParameters;
+ private static SupervisionHandler supervisionHandler;
+ private static CommissioningHandler commissioningHandler;
/**
* setup Db Provider Parameters.
@@ -82,18 +92,21 @@ public class ControlLoopInstantiationProviderTest {
public static void setupDbProviderParameters() throws PfModelException {
databaseProviderParameters =
CommonTestData.geParameterGroup(0, "instantproviderdb").getDatabaseProviderParameters();
+ commissioningHandler = new CommissioningHandler(CommonTestData.geParameterGroup(0, "instantproviderdb"));
+ commissioningHandler.startProviders();
+ supervisionHandler = new SupervisionHandler(CommonTestData.geParameterGroup(0, "instantproviderdb"));
+ supervisionHandler.startProviders();
+ supervisionHandler.startAndRegisterPublishers(Collections.singletonList(Mockito.mock(TopicSink.class)));
}
@Test
public void testInstantiationCrud() throws Exception {
ControlLoops controlLoopsCreate =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Crud");
-
ControlLoops controlLoopsDb = getControlLoopsFromDb(controlLoopsCreate);
assertThat(controlLoopsDb.getControlLoopList()).isEmpty();
-
try (ControlLoopInstantiationProvider instantiationProvider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
// to validate control Loop, it needs to define ToscaServiceTemplate
InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
@@ -154,7 +167,7 @@ public class ControlLoopInstantiationProviderTest {
controlLoopsDb.setControlLoopList(new ArrayList<>());
try (ControlLoopInstantiationProvider instantiationProvider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
for (ControlLoop controlLoop : controlLoopsSource.getControlLoopList()) {
ControlLoops controlLoopsFromDb =
@@ -174,14 +187,14 @@ public class ControlLoopInstantiationProviderTest {
ControlLoop controlLoop0 = controlLoops.getControlLoopList().get(0);
try (ControlLoopInstantiationProvider instantiationProvider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
// to validate control Loop, it needs to define ToscaServiceTemplate
InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
assertThatThrownBy(
() -> instantiationProvider.deleteControlLoop(controlLoop0.getName(), controlLoop0.getVersion()))
- .hasMessageMatching(CONTROL_LOOP_NOT_FOUND);
+ .hasMessageMatching(CONTROL_LOOP_NOT_FOUND);
InstantiationUtils.assertInstantiationResponse(instantiationProvider.createControlLoops(controlLoops),
controlLoops);
@@ -213,12 +226,12 @@ public class ControlLoopInstantiationProviderTest {
controlLoop.setState(state);
try (ControlLoopInstantiationProvider instantiationProvider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
instantiationProvider.updateControlLoops(controlLoops);
assertThatThrownBy(
() -> instantiationProvider.deleteControlLoop(controlLoop.getName(), controlLoop.getVersion()))
- .hasMessageMatching(String.format(DELETE_BAD_REQUEST, state));
+ .hasMessageMatching(String.format(DELETE_BAD_REQUEST, state));
}
}
@@ -231,7 +244,7 @@ public class ControlLoopInstantiationProviderTest {
assertThat(controlLoopsDb.getControlLoopList()).isEmpty();
try (ControlLoopInstantiationProvider instantiationProvider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
// to validate control Loop, it needs to define ToscaServiceTemplate
InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
@@ -254,7 +267,7 @@ public class ControlLoopInstantiationProviderTest {
.getControlLoopsFromResource(CL_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON, "ClElementNotFound");
try (ControlLoopInstantiationProvider provider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
// to validate control Loop, it needs to define ToscaServiceTemplate
InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
@@ -274,7 +287,7 @@ public class ControlLoopInstantiationProviderTest {
assertThat(getControlLoopsFromDb(controlLoops).getControlLoopList()).isEmpty();
try (ControlLoopInstantiationProvider provider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
assertThatThrownBy(() -> provider.createControlLoops(controlLoops))
.hasMessageMatching(CONTROLLOOP_DEFINITION_NOT_FOUND);
}
@@ -283,7 +296,7 @@ public class ControlLoopInstantiationProviderTest {
@Test
public void testIssueControlLoopCommand_OrderedStateInvalid() throws ControlLoopRuntimeException, IOException {
try (ControlLoopInstantiationProvider instantiationProvider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
assertThatThrownBy(() -> instantiationProvider.issueControlLoopCommand(new InstantiationCommand()))
.hasMessageMatching(ORDERED_STATE_INVALID);
}
@@ -298,7 +311,7 @@ public class ControlLoopInstantiationProviderTest {
assertThat(getControlLoopsFromDb(controlLoopsV1).getControlLoopList()).isEmpty();
try (ControlLoopInstantiationProvider instantiationProvider =
- new ControlLoopInstantiationProvider(databaseProviderParameters)) {
+ new ControlLoopInstantiationProvider(databaseProviderParameters)) {
// to validate control Loop, it needs to define ToscaServiceTemplate
InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, databaseProviderParameters);
diff --git a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
index 63d5a52a4..71e762455 100644
--- a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
+++ b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
@@ -54,12 +54,13 @@ public class InstantiationControllerTest extends CommonRestController {
private static final String CL_INSTANTIATION_CHANGE_STATE_JSON =
"src/test/resources/rest/controlloops/PassiveCommand.json";
+ private static final String TOSCA_TEMPLATE_YAML =
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+
private static final String INSTANTIATION_ENDPOINT = "instantiation";
private static final String INSTANTIATION_COMMAND_ENDPOINT = "instantiation/command";
- private static final String TOSCA_TEMPLATE_YAML = "examples/controlloop/PMSubscriptionHandling.yaml";
-
/**
* starts Main and inserts a commissioning template.
*
diff --git a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java
index 6dd4031ed..b06383c68 100644
--- a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java
+++ b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/MainTest.java
@@ -152,6 +152,6 @@ public class MainTest {
private void assertThatConfigFileThrownException(final String configFilePath) {
final String[] configParameters = new String[] {"-c", configFilePath};
assertThatThrownBy(() -> new Main(configParameters)).isInstanceOf(ControlLoopRuntimeException.class)
- .hasMessage(POLICY_CLAMP_FAILURE_MSG);
+ .hasMessage(String.format(POLICY_CLAMP_FAILURE_MSG));
}
}
diff --git a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
index 888fb1e98..44096eecd 100644
--- a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
+++ b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
@@ -29,7 +29,7 @@ import java.io.File;
import java.lang.reflect.Field;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.junit.BeforeClass;
@@ -231,7 +231,8 @@ public class TestMonitoringProvider {
.get(0).getParticipantId().getName(), inputClElementStatistics.getClElementStatistics().get(0)
.getParticipantId().getVersion()));
ControlLoop mockCL = new ControlLoop();
- mockCL.setElements(Arrays.asList(mockClElement));
+ mockCL.setElements(new LinkedHashMap<>());
+ mockCL.getElements().put(mockClElement.getId(), mockClElement);
//Mock controlloop data to be returned for the given CL Id
ControlLoopProvider mockClProvider = Mockito.mock(ControlLoopProvider.class);
diff --git a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
index 31d4be472..77f802d61 100644
--- a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
+++ b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
@@ -57,7 +57,7 @@ public class CommonTestData {
* @return the standard Control Loop parameters as string
*/
public static String getParameterGroupAsString(final int port, final String dbName) {
- return ResourceUtils.getResourceAsString("src/test/resources/parameters/ConfigParametersStd.json")
+ return ResourceUtils.getResourceAsString("src/test/resources/parameters/InstantiationConfigParametersStd.json")
.replace("${port}", String.valueOf(port)).replace("${dbName}", "jdbc:h2:mem:" + dbName);
}
}
diff --git a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java
index 83cfe9b52..0d668f139 100644
--- a/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java
+++ b/tosca-controlloop/runtime/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java
@@ -260,4 +260,4 @@ public class CommonRestController {
Response rawresp = sendNoAuthRequest(endPoint).delete();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
-}
+} \ No newline at end of file
diff --git a/tosca-controlloop/runtime/src/test/resources/META-INF/persistence.xml b/tosca-controlloop/runtime/src/test/resources/META-INF/persistence.xml
index 5df575c22..6e31cca47 100644
--- a/tosca-controlloop/runtime/src/test/resources/META-INF/persistence.xml
+++ b/tosca-controlloop/runtime/src/test/resources/META-INF/persistence.xml
@@ -19,6 +19,64 @@
============LICENSE_END=========================================================
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+ <persistence-unit name="CommissioningMariaDb" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.base.PfConceptKey</class>
+ <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
+ <class>org.onap.policy.models.dao.converters.Uuid2String</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics</class>
+ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+
+ <!-- property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level.jpa" value="ALL" />
+ <property name="eclipselink.logging.level.ddl" value="ALL" />
+ <property name="eclipselink.logging.level.connection" value="ALL" />
+ <property name="eclipselink.logging.level.sql" value="ALL" />
+ <property name="eclipselink.logging.level.transaction" value="ALL" />
+ <property name="eclipselink.logging.level.sequencing" value="ALL" />
+ <property name="eclipselink.logging.level.server" value="ALL" />
+ <property name="eclipselink.logging.level.query" value="ALL" />
+ <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
<persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
@@ -50,6 +108,7 @@
<class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
<properties>
+ <property name="eclipselink.target-database" value="MySQL" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO" />
@@ -57,4 +116,44 @@
<shared-cache-mode>NONE</shared-cache-mode>
</persistence-unit>
+ <persistence-unit name="InstantiationTests" transaction-type="RESOURCE_LOCAL">
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplates</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaParameter</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipType</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRelationshipTypes</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirement</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaRequirements</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
+ <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
+
+ <properties>
+ <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ <property name="eclipselink.logging.level" value="INFO" />
+ </properties>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ </persistence-unit>
+
</persistence>
+
diff --git a/tosca-controlloop/runtime/src/test/resources/parameters/CommissioningConfig.json b/tosca-controlloop/runtime/src/test/resources/parameters/CommissioningConfig.json
new file mode 100644
index 000000000..bda9da6a1
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/parameters/CommissioningConfig.json
@@ -0,0 +1,20 @@
+{
+ "name": "CommissioningGroup",
+ "restServerParameters": {
+ "host": "127.0.0.1",
+ "port": 6969,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "databaseProviderParameters": {
+ "name": "CommissioningProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "controlloop",
+ "databasePassword": "C0ntr0lL00p",
+ "persistenceUnit": "ToscaConceptTest"
+ }
+}
diff --git a/tosca-controlloop/runtime/src/test/resources/parameters/ConfigParametersStd.json b/tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParametersStd.json
index 19346a059..7682a1812 100644
--- a/tosca-controlloop/runtime/src/test/resources/parameters/ConfigParametersStd.json
+++ b/tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParametersStd.json
@@ -26,7 +26,7 @@
"databaseUrl": "${dbName}",
"databaseUser": "policy",
"databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
+ "persistenceUnit": "InstantiationTests"
},
"topicParameterGroup": {
"topicSources": [
diff --git a/tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json b/tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json
new file mode 100644
index 000000000..b0c322cb9
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json
@@ -0,0 +1,31 @@
+{
+ "name":" ",
+ "restServerParameters": {
+ "host": "127.0.0.1",
+ "port": 6969,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "pdpParameters": {
+ "heartBeatMs": 1,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 1
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 1
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "PdpGroupTest"
+ }
+}
diff --git a/tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParameters_sim.json b/tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParameters_sim.json
new file mode 100644
index 000000000..0977da9ad
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/parameters/InstantiationConfigParameters_sim.json
@@ -0,0 +1,43 @@
+{
+ "name": "Instantiation",
+ "restServerParameters": {
+ "host": "127.0.0.1",
+ "port": 6969,
+ "userName": "admin",
+ "password": "password",
+ "https": false,
+ "aaf": false
+ },
+ "pdpParameters": {
+ "heartBeatMs": 10,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/policyadmin",
+ "databaseUser": "policy",
+ "databasePassword": "UDAxaWNZ",
+ "persistenceUnit": "PolicyMariaDb"
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "INSTANTIATION",
+ "servers" : [ "localhost:6845" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "INSTANTIATION",
+ "servers" : [ "localhost:6845" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
+ }
+}
diff --git a/tosca-controlloop/runtime/src/test/resources/parameters/MinimumParametersH2.json b/tosca-controlloop/runtime/src/test/resources/parameters/MinimumParametersH2.json
new file mode 100644
index 000000000..f784dcd16
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/parameters/MinimumParametersH2.json
@@ -0,0 +1,59 @@
+{
+ "name":"PapGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
+ "pdpParameters": {
+ "heartBeatMs": 1,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 1
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 1
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.h2.Driver",
+ "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "PdpGroupTest"
+ },
+ "topicParameterGroup": {
+ "topicSources" : [{
+ "topic" : "POLICY-PDP-PAP",
+ "servers" : [ "message-router" ],
+ "topicCommInfrastructure" : "dmaap"
+ }],
+ "topicSinks" : [{
+ "topic" : "POLICY-PDP-PAP",
+ "servers" : [ "message-router" ],
+ "topicCommInfrastructure" : "dmaap"
+ }]
+ },
+ "healthCheckRestClientParameters":[{
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }]
+}
diff --git a/tosca-controlloop/runtime/src/test/resources/parameters/TestParametersMariaDB.json b/tosca-controlloop/runtime/src/test/resources/parameters/TestParametersMariaDB.json
new file mode 100644
index 000000000..2c0127b16
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/parameters/TestParametersMariaDB.json
@@ -0,0 +1,79 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/controlloop",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "CommissioningMariaDb"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "localhost"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ },
+ "healthCheckRestClientParameters": [
+ {
+ "clientName": "api",
+ "hostname": "policy-api",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "policy/api/v1/healthcheck"
+ },
+ {
+ "clientName": "distribution",
+ "hostname": "policy-distribution",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "useHttps": true,
+ "basePath": "healthcheck"
+ }
+ ]
+}
diff --git a/tosca-controlloop/runtime/src/test/resources/parameters/Unreadable.json b/tosca-controlloop/runtime/src/test/resources/parameters/Unreadable.json
index e69de158b..3d117f416 100644
--- a/tosca-controlloop/runtime/src/test/resources/parameters/Unreadable.json
+++ b/tosca-controlloop/runtime/src/test/resources/parameters/Unreadable.json
@@ -76,4 +76,3 @@
"basePath": "healthcheck"
}
]
- \ No newline at end of file
diff --git a/tosca-controlloop/runtime/src/test/resources/parameters/logback-test.xml b/tosca-controlloop/runtime/src/test/resources/parameters/logback-test.xml
new file mode 100644
index 000000000..e00c36baa
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/parameters/logback-test.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============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=========================================================
+-->
+
+<configuration>
+
+ <contextName>Apex</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ <property name="LOG_DIR" value="${java.io.tmpdir}/clamp_logging/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.onap.policy.clamp.controlloop.runtime" level="trace" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>
diff --git a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsElementsNotFound.json b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json
index 2c8ca20d4..faea7cd48 100644
--- a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsElementsNotFound.json
+++ b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopElementsNotFound.json
@@ -10,64 +10,64 @@
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "PMSH control loop instance 0",
- "elements": [
- {
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
"definition": {
- "name": "org.onap.domain.pmsh.NotExistFirst",
+ "name": "org.onap.domain.pmsh.DCAEMicroservice",
"version": "1.2.3"
},
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "CDSParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "CDS Control Loop Element for the PMSH instance 0 control loop"
}
- ]
+ }
},
{
"name": "PMSHInstance1",
@@ -79,64 +79,64 @@
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "PMSH control loop instance 1",
- "elements": [
- {
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
"definition": {
- "name": "org.onap.domain.pmsh.NotExistSecond",
+ "name": "org.onap.domain.pmsh.DCAEMicroservice",
"version": "1.2.3"
},
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "CDSParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "CDS Control Loop Element for the PMSH instance 1 control loop"
}
- ]
+ }
}
]
}
diff --git a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoops.json b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoops.json
index 94c6a619f..13ea1bfc4 100644
--- a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoops.json
+++ b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoops.json
@@ -10,64 +10,64 @@
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "PMSH control loop instance 0",
- "elements": [
- {
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "CDSParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "CDS Control Loop Element for the PMSH instance 0 control loop"
}
- ]
+ }
},
{
"name": "PMSHInstance1",
@@ -79,64 +79,64 @@
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "PMSH control loop instance 1",
- "elements": [
- {
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "CDSParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "CDS Control Loop Element for the PMSH instance 1 control loop"
}
- ]
+ }
}
]
}
diff --git a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsNotFound.json b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsNotFound.json
index 2e13c688f..9e9767472 100644
--- a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsNotFound.json
+++ b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsNotFound.json
@@ -10,64 +10,64 @@
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "PMSH control loop instance 0",
- "elements": [
- {
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "CDSParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "CDS Control Loop Element for the PMSH instance 0 control loop"
}
- ]
+ }
},
{
"name": "PMSHInstance1",
@@ -79,64 +79,64 @@
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "PMSH control loop instance 1",
- "elements": [
- {
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "CDSParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "CDS Control Loop Element for the PMSH instance 1 control loop"
}
- ]
+ }
}
]
}
diff --git a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsUpdate.json b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsUpdate.json
index 9dce01ae4..025e2a1fb 100644
--- a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsUpdate.json
+++ b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsUpdate.json
@@ -10,64 +10,64 @@
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "PMSH control loop instance 1",
- "elements": [
- {
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
"id": "709c62b3-8918-41b9-a747-d21eb79c6c24",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "CDSParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "CDS Control Loop Element for the PMSH instance 0 control loop"
}
- ]
+ }
},
{
"name": "PMSHInstance1",
@@ -79,64 +79,64 @@
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "PMSH control loop instance 1",
- "elements": [
- {
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
"version": "1.2.3"
},
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
},
- {
+ "709c62b3-8918-41b9-a747-d21eb79c6c28": {
"id": "709c62b3-8918-41b9-a747-e21eb79c6c28",
"definition": {
"name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "CDSParticipant0",
- "version": "1.0.0"
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
},
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "CDS Control Loop Element for the PMSH instance 1 control loop"
}
- ]
+ }
}
]
}
diff --git a/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json
new file mode 100644
index 000000000..76131afc1
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/rest/controlloops/ControlLoopsVersionNotMatches.json
@@ -0,0 +1,142 @@
+{
+ "controlLoopList": [
+ {
+ "name": "PMSHInstance0",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 0",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c20": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c20",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c21": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c21",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c22": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c22",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c23": {
+ "id": "709c62b3-8918-41b9-a747-d21eb79c6c23",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 0 control loop"
+ }
+ }
+ },
+ {
+ "name": "PMSHInstance1",
+ "version": "1.0.1",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "PMSH control loop instance 1",
+ "elements": {
+ "709c62b3-8918-41b9-a747-d21eb79c6c24": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c24",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "DCAE Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c25": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c25",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Monitoring Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c26": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c26",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "Operational Policy Control Loop Element for the PMSH instance 1 control loop"
+ },
+ "709c62b3-8918-41b9-a747-d21eb79c6c27": {
+ "id": "709c62b3-8918-41b9-a747-e21eb79c6c27",
+ "definition": {
+ "name": "org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement",
+ "version": "1.2.3"
+ },
+ "participantType": {
+ "name": "org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant",
+ "version": "2.2.1"
+ },
+ "state": "UNINITIALISED",
+ "orderedState": "UNINITIALISED",
+ "description": "CDS Control Loop Element for the PMSH instance 1 control loop"
+ }
+ }
+ }
+ ]
+}
diff --git a/tosca-controlloop/runtime/src/test/resources/servicetemplates/pmsh_multiple_cl_tosca.yaml b/tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml
index 099e2e945..099e2e945 100644
--- a/tosca-controlloop/runtime/src/test/resources/servicetemplates/pmsh_multiple_cl_tosca.yaml
+++ b/tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/PMSHMultipleCLTosca.yaml
diff --git a/tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml b/tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
new file mode 100644
index 000000000..01f825fc9
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/pm_control_loop_tosca.yaml
@@ -0,0 +1,452 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+capability_types:
+ org.onap.EventProducer:
+ properties:
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ event_format:
+ type: string
+ required: true
+ event_format_version:
+ type: string
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+ org.onap.EventConsumer:
+ properties:
+ responding_capability:
+ type: string
+ required: false
+ carrier_protocol_type:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ data_format:
+ type: string
+ required: true
+ constraints:
+ - valid_values:
+ - JSON
+ - YAML
+ - JMS
+ - all valid values should be added here
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, LinkUp, VnfConfigured,
+ etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: false
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key may be generated
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ version: 0.0.1
+ derived_from: tosca.capabilities.Root
+node_types:
+ org.onap.DynamicConfig:
+ properties:
+ application_name:
+ type: string
+ description: Value used to tie the config to an application ? should we be
+ using a relationship here instead?
+ required: true
+ application_version:
+ type: string
+ required: true
+ application_provider:
+ type: string
+ required: false
+ data_types:
+ type: object
+ required: false
+ schema:
+ type: object
+ required: false
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.APP:
+ properties:
+ application_name:
+ type: string
+ description: Human readable name for the application Product
+ required: false
+ provider:
+ type: string
+ description: Provider of the application and of the descriptor
+ required: true
+ application_version:
+ type: string
+ description: Software version of the application
+ required: true
+ blueprint_id:
+ type: string
+ description: A reference to the app blueprint
+ required: false
+ monitoring_policy:
+ type: string
+ description: A reference to the monitoring policy
+ required: false
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+ org.onap.EventRelay:
+ properties:
+ event_format:
+ type: string
+ description: 'examples for event_format: Ves_specification, etc.'
+ required: true
+ event_format_version:
+ type: string
+ description: 'examples for event_format_version: 5.28.4, 7.30.1, etc.'
+ required: true
+ config_keys:
+ type: list
+ required: false
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - all valid values should be added here
+ - if not specified, events of any config key is relayed
+ - 'examples for config_key: ves-measurement, ves-syslog, tca_handle_out,
+ etc.'
+ supported_carrier_protocols:
+ type: map
+ description: 'A map describing supported carrier protocols and translations.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { REST: REST, DMAAP: REST, DMAAP: DMAAP}'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - DMAAP_message_router
+ - SOMETHING_ELSE
+ - REST
+ - all valid values should be added here
+ supported_data_formats:
+ type: map
+ description: 'Is a map describing supported data formats and translation.
+ The tuples define what protocol combinations are supported on the producer
+ and consumer side: e.g. { JSON: JSON, JMS: JSON, YAML:YAML }'
+ required: true
+ key_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ entry_schema:
+ type: string
+ constraints:
+ - valid_values:
+ - JSON
+ - JMS
+ - YAML
+ - etc
+ - all valid values should be added here
+ requirements:
+ - receive:
+ capability: org.onap.EventProducer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ - send:
+ capability: org.onap.EventConsumer
+ relationship: org.onap.PropagateEvent
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.1
+ derived_from: tosca.nodes.Root
+relationship_types:
+ org.onap.PropagateEvent:
+ properties:
+ config_keys:
+ type: list
+ description: The relationship type used on requirements to org.onap.EventProducer
+ and org.onap.EventConsumer capabilities. Filters events by specific config_keys
+ to be transferred by this relationship. That is, any event with a specific
+ config_key found in the list is transferred. If list is not defined or is
+ empty, events with all config_keys are transferred.
+ required: false
+ entry_schema:
+ type: string
+ version: 0.0.1
+ derived_from: tosca.relationships.Root
+topology_template:
+ inputs:
+ pm_subscription_topic:
+ type: string
+ pm_subscription_response_topic:
+ type: string
+ pm_subscription_handler_blueprint_id:
+ type: string
+ pm_subscription_operational_policy_id:
+ type: string
+ pm_subscription_cds_blueprint_id:
+ type: string
+ enable_tls:
+ type: string
+ node_templates:
+ org.onap.PM_Subscription_Handler:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Handler
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_handler_blueprint_id
+ description: Is this a reference to the DCAE Cloudify Blueprint that is
+ already stored(or will be stored before CL configuration & instatiation)
+ in DCAE Inventory?
+ artifact_config:
+ enable_tls:
+ get_input: enable_tls
+ pmsh_publish_topic_name:
+ get_input: pm_subscription_topic
+ capabilities:
+ pm-subscription-event-publisher:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-format
+ event_format_version: 1.0.0
+ attributes:
+ type: org.onap.EventProducer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ pm-subscription-event-receiver:
+ properties:
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ relationships:
+ - type: tosca.relationships.DependsOn
+ - description: any ideas on a better realtionship ? or is it better to
+ just use the root realtionship ?
+ - target: org.onap.PM_Monitoring_Policy
+ attributes:
+ type: org.onap.EventConsumer
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_Monitoring_Policy:
+ type: org.onap.DynamicConfig
+ properties:
+ application_name: PM Subscription Handler
+ application_version: 1.0.0
+ provider: Ericsson
+ data_types:
+ measurementType:
+ type: string
+ DN:
+ type: string
+ nfFilter:
+ properties:
+ nfNames:
+ type: list
+ entry_schema: string
+ modelInvariantIDs:
+ type: list
+ entry_schema:
+ type: string
+ modelVersionIDs:
+ type: list
+ entry_schema:
+ type: string
+ measurementGroup:
+ properties:
+ masurementTypes:
+ type: list
+ entry_schema:
+ type: measurementType
+ managedObjectDNsBasic:
+ type: list
+ entry_schema:
+ type: DN
+ schema:
+ subscription:
+ subscriptionName:
+ type: string
+ required: true
+ administrativeState:
+ type: string
+ required: true
+ filebasedGP:
+ type: integer
+ required: true
+ fileLocation:
+ type: string
+ required: true
+ nfFilter:
+ type: nfFilter
+ measurementGroups:
+ type: list
+ entry_schema:
+ type: measurementGroup
+ version: 0.0.0
+ description: Should I be showing a dependency between PM Subscription Handler
+ and the PM Monitoring Policy
+ org.onap.PM_Policy:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription Operational Policy
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_operational_policy_id
+ artifact_config: NOT_DEFINED
+ requirements:
+ - receive_0:
+ capability: pm-subscription-event-publisher
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_topic
+ version: 0.0.0
+ - send_0:
+ capability: cds-rest-receive
+ node: org.onap.CDS
+ version: 0.0.0
+ - receive_1:
+ capability: cds-rest-response
+ node: org.onap.CDS
+ version: 0.0.0
+ - send_1:
+ capability: pm-subscription-event-receiver
+ node: org.onap.PM_Subscription_Handler
+ relationship: NOT_DEFINED
+ properties:
+ config_keys:
+ - topic_name:
+ get_input: pm_subscription_response_topic
+ version: 0.0.0
+ capabilities:
+ pm-subscription-response-event-publisher:
+ properties:
+ type: org.onap.EventProducer
+ carrier_protocol_type: DMAAP_message_router
+ data_format: JSON
+ event_format: pm-subscription-event-response-format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.PM_CDS_Blueprint:
+ type: org.onap.APP
+ properties:
+ application_name: PM Subscription CDS Blueprint
+ provider: Ericsson
+ application_version: 1.0.0
+ artifact_id:
+ get_input: pm_subscription_cds_blueprint_id
+ capabilities:
+ cds-rest-receive:
+ properties:
+ type: org.onap.EventConsumer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_format
+ event_format_version: 1.0.0
+ responding_capability: cds-rest-response
+ occurrences:
+ - 0.0
+ - UNBOUNDED
+ version: 0.0.0
+ cds-rest-response:
+ properties:
+ type: org.onap.EventProducer
+ protocol_type: REST
+ data_format: JSON
+ event_format: cds_action_response_format
+ event_format_version: 1.0.0
+ occurrences:
+ - 0.0
+ version: 0.0.0
+ version: 0.0.0
+ org.onap.controlloop0:
+ type: org.onap.APP
+ properties:
+ application_name: Test Control Loop
+ provider: Ericsson
+ application_version: 1.0.0
+ status: NOT_DEPLOYED
+ version: 0.0.0
+version: 0.0.0
diff --git a/tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml b/tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
new file mode 100644
index 000000000..099e2e945
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml
@@ -0,0 +1,221 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+data_types:
+ onap.datatypes.ToscaConceptIdentifier:
+ derived_from: tosca.datatypes.Root
+ properties:
+ name:
+ type: string
+ required: true
+ version:
+ type: string
+ required: true
+node_types:
+ org.onap.policy.clamp.controlloop.Participant:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ org.onap.policy.clamp.controlloop.ControlLoopElement:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ participant_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.ControlLoop:
+ version: 1.0.1
+ derived_from: tosca.nodetypes.Root
+ properties:
+ provider:
+ type: string
+ requred: false
+ elements:
+ type: list
+ required: true
+ entry_schema:
+ type: onap.datatypes.ToscaConceptIdentifier
+ org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ dcae_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ policy_type_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+ org.onap.policy.clamp.controlloop.CDSControlLoopElement:
+ version: 1.0.1
+ derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement
+ properties:
+ cds_blueprint_id:
+ type: onap.datatypes.ToscaConceptIdentifier
+ requred: true
+topology_template:
+ node_templates:
+ org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant:
+ version: 2.3.4
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.policy.controlloop.PolicyControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant:
+ version: 2.2.1
+ type: org.onap.policy.clamp.controlloop.Participant
+ type_version: 1.0.1
+ description: Participant for DCAE microservices
+ properties:
+ provider: ONAP
+ org.onap.domain.pmsh.PMSH_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint_id:
+ name: org.onap.dcae.blueprints.PMSHBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSHCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSHControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSH_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSH_CDS_ControlLoopElement
+ version: 1.2.3
+ org.onap.domain.pmsh.PMSD_DCAEMicroservice:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.DCAEMicroserviceControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the DCAE microservice for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ dcae_blueprint_id:
+ name: org.onap.dcae.blueprints.PMSDBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the monitoring policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.monitoring.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.PolicyTypeControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for the operational policy for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_id:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.2.1
+ policy_type_id:
+ name: onap.policies.operational.pm-subscription-handler
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoopElement
+ type_version: 1.0.0
+ description: Control loop element for CDS for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ participant_Id:
+ name: org.onap.ccsdk.cds.controlloop.CdsControlLoopParticipant
+ version: 3.2.1
+ cds_blueprint_id:
+ name: org.onap.ccsdk.cds.PMSDCdsBlueprint
+ version: 1.0.0
+ org.onap.domain.pmsh.PMSDControlLoopDefinition:
+ version: 1.2.3
+ type: org.onap.policy.clamp.controlloop.ControlLoop
+ type_version: 1.0.0
+ description: Control loop for Performance Management Subscription Handling
+ properties:
+ provider: Ericsson
+ elements:
+ - name: org.onap.domain.pmsh.PMSD_DCAEMicroservice
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_MonitoringPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_OperationalPolicyControlLoopElement
+ version: 1.2.3
+ - name: org.onap.domain.pmsh.PMSD_CDS_ControlLoopElement
+ version: 1.2.3
diff --git a/tosca-controlloop/runtime/src/test/resources/testscripts/listenOnTopic.sh b/tosca-controlloop/runtime/src/test/resources/testscripts/listenOnTopic.sh
new file mode 100644
index 000000000..5e661777b
--- /dev/null
+++ b/tosca-controlloop/runtime/src/test/resources/testscripts/listenOnTopic.sh
@@ -0,0 +1,31 @@
+#! /bin/bash
+# ============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=========================================================
+
+if [ $# -ne 1 ]
+then
+ echo invalid parameters $*, specify a single parameter as the topic to listen on
+ exit 1
+fi
+
+while true
+do
+ curl "http://localhost:3904/events/$1/TEST/1?timeout=60000"
+ echo ""
+done
+