summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-controlloop')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java2
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java46
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java72
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java28
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java19
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java20
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java15
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java126
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java62
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java (renamed from runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PropertiesConfig.java)24
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java67
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java32
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java67
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java2
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java68
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java32
-rw-r--r--runtime-controlloop/src/main/resources/application.yaml31
-rw-r--r--runtime-controlloop/src/main/resources/parameters/ClRuntimeParameters.json56
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java31
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java5
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java11
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java17
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java226
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java14
-rw-r--r--runtime-controlloop/src/test/resources/application_test.properties24
-rw-r--r--runtime-controlloop/src/test/resources/parameters/CommissioningConfig.json24
-rw-r--r--runtime-controlloop/src/test/resources/parameters/EmptyParameters.json0
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json63
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json35
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_sim.json55
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InvalidParameters.json3
-rw-r--r--runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json53
-rw-r--r--runtime-controlloop/src/test/resources/parameters/NoParameters.json2
-rw-r--r--runtime-controlloop/src/test/resources/parameters/TestParameters.json12
-rw-r--r--runtime-controlloop/src/test/resources/parameters/Unreadable.json62
36 files changed, 842 insertions, 567 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java
index 6b772513c..28814b354 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java
@@ -22,11 +22,13 @@ package org.onap.policy.clamp.controlloop.runtime;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan({"org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider",
"org.onap.policy.clamp.controlloop.runtime"})
+@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.runtime.main.parameters")
public class Application {
public static void main(String[] args) {
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
index bf6e39914..d9dee50bc 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -227,7 +227,8 @@ public class CommissioningProvider {
mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaTopologyTemplate.class), visitor);
break;
case "node_templates":
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaNodeTemplate.class), visitor);
+ mapper.acceptJsonFormatVisitor(mapper.getTypeFactory()
+ .constructCollectionType(List.class, ToscaNodeTemplate.class), visitor);
break;
default:
mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaServiceTemplate.class), visitor);
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
index d1fa31261..f46b90294 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
@@ -20,38 +20,52 @@
package org.onap.policy.clamp.controlloop.runtime.main.parameters;
-import javax.validation.constraints.NotBlank;
+import javax.validation.Valid;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
import lombok.Getter;
-import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import lombok.Setter;
import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
/**
* Class to hold all parameters needed for the Control Loop runtime component.
*
*/
-@NotNull
-@NotBlank
+@Validated
@Getter
-public class ClRuntimeParameterGroup extends ParameterGroupImpl {
- private RestServerParameters restServerParameters;
+@Setter
+@ConfigurationProperties(prefix = "runtime")
+public class ClRuntimeParameterGroup {
+
+ @NotNull
+ @ParameterGroupConstraint
private PolicyModelsProviderParameters databaseProviderParameters;
+
+ @Valid
+ @NotNull
private ParticipantParameters participantParameters;
+
+ @NotNull
+ @ParameterGroupConstraint
private TopicParameterGroup topicParameterGroup;
+ @Min(value = 0)
private long supervisionScannerIntervalSec;
+
+ @Min(value = 0)
private long participantStateChangeIntervalSec;
+
+ @Min(value = 0)
private long participantClUpdateIntervalSec;
+
+ @Min(value = 0)
private long participantClStateChangeIntervalSec;
+ private long participantRegisterAckIntervalSec;
+ private long participantDeregisterAckIntervalSec;
+ private long participantUpdateIntervalSec;
- /**
- * Create the Control Loop parameter group.
- *
- * @param name the parameter group name
- */
- public ClRuntimeParameterGroup(final String name) {
- super(name);
- }
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java
deleted file mode 100644
index bcf1124d2..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterHandler.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.runtime.main.parameters;
-
-import java.io.File;
-import javax.ws.rs.core.Response;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-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;
-
-/**
- * This class handles reading, parsing and validating of control loop runtime parameters from JSON files.
- */
-public class ClRuntimeParameterHandler {
-
- private static final Coder CODER = new StandardCoder();
-
- /**
- * Read the parameters from the parameter file.
- *
- * @param path the path passed to control loop runtime
- * @return the parameters read from the configuration file
- * @throws ControlLoopException on parameter exceptions
- */
- public ClRuntimeParameterGroup getParameters(final String path) throws ControlLoopException {
- ClRuntimeParameterGroup clRuntimeParameterGroup = null;
-
- // Read the parameters
- try {
- // Read the parameters from JSON
- File file = new File(path);
- clRuntimeParameterGroup = CODER.decode(file, ClRuntimeParameterGroup.class);
- } catch (final CoderException e) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- "error reading parameters from \"" + path + "\"\n" + "(" + e.getClass().getSimpleName() + ")", e);
- }
-
- // The JSON processing returns null if there is an empty file
- if (clRuntimeParameterGroup == null) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, "no parameters found in \"" + path + "\"");
- }
-
- // validate the parameters
- final ValidationResult validationResult = clRuntimeParameterGroup.validate();
- if (!validationResult.isValid()) {
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- "validation error(s) on parameters from \"" + path + "\"\n" + validationResult.getResult());
- }
-
- return clRuntimeParameterGroup;
- }
-}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java
index dfc1b2806..a4e84af0d 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantParameters.java
@@ -19,19 +19,20 @@
package org.onap.policy.clamp.controlloop.runtime.main.parameters;
import java.util.concurrent.TimeUnit;
+import javax.validation.Valid;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
import lombok.Getter;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.Min;
-import org.onap.policy.common.parameters.annotations.NotBlank;
-import org.onap.policy.common.parameters.annotations.NotNull;
+import lombok.Setter;
+import org.springframework.validation.annotation.Validated;
/**
* Parameters for communicating with participants.
*/
-@NotNull
-@NotBlank
@Getter
-public class ParticipantParameters extends ParameterGroupImpl {
+@Setter
+@Validated
+public class ParticipantParameters {
/**
* Default maximum message age, in milliseconds, that should be examined. Any message
@@ -39,21 +40,18 @@ public class ParticipantParameters extends ParameterGroupImpl {
*/
public static final long DEFAULT_MAX_AGE_MS = TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES);
-
@Min(1)
private long heartBeatMs;
@Min(1)
private long maxMessageAgeMs = DEFAULT_MAX_AGE_MS;
+ @Valid
+ @NotNull
private ParticipantUpdateParameters updateParameters;
- private ParticipantStateChangeParameters stateChangeParameters;
+ @Valid
+ @NotNull
+ private ParticipantStateChangeParameters stateChangeParameters;
- /**
- * Constructs the object.
- */
- public ParticipantParameters() {
- super(ParticipantParameters.class.getSimpleName());
- }
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java
index 2eea4ab51..a3e2eee2e 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantStateChangeParameters.java
@@ -18,19 +18,18 @@
package org.onap.policy.clamp.controlloop.runtime.main.parameters;
+import javax.validation.constraints.Min;
import lombok.Getter;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.Min;
-import org.onap.policy.common.parameters.annotations.NotBlank;
-import org.onap.policy.common.parameters.annotations.NotNull;
+import lombok.Setter;
+import org.springframework.validation.annotation.Validated;
/**
* Parameters for Participant STATE-CHANGE requests.
*/
-@NotNull
-@NotBlank
@Getter
-public class ParticipantStateChangeParameters extends ParameterGroupImpl {
+@Setter
+@Validated
+public class ParticipantStateChangeParameters {
/**
* Maximum number of times to re-send a request to a PDP.
@@ -44,10 +43,4 @@ public class ParticipantStateChangeParameters extends ParameterGroupImpl {
@Min(value = 0)
private long maxWaitMs;
- /**
- * Constructs the object.
- */
- public ParticipantStateChangeParameters() {
- super(ParticipantStateChangeParameters.class.getSimpleName());
- }
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
index 2af5be534..8102fe90e 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ParticipantUpdateParameters.java
@@ -18,19 +18,18 @@
package org.onap.policy.clamp.controlloop.runtime.main.parameters;
+import javax.validation.constraints.Min;
import lombok.Getter;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.Min;
-import org.onap.policy.common.parameters.annotations.NotBlank;
-import org.onap.policy.common.parameters.annotations.NotNull;
+import lombok.Setter;
+import org.springframework.validation.annotation.Validated;
/**
* Parameters for Participant UPDATE requests.
*/
-@NotNull
-@NotBlank
@Getter
-public class ParticipantUpdateParameters extends ParameterGroupImpl {
+@Setter
+@Validated
+public class ParticipantUpdateParameters {
/**
* Maximum number of times to re-send a request to a PDP.
@@ -44,11 +43,4 @@ public class ParticipantUpdateParameters extends ParameterGroupImpl {
@Min(value = 0)
private long maxWaitMs;
- /**
- * Constructs the object.
- */
- public ParticipantUpdateParameters() {
- super(ParticipantUpdateParameters.class.getSimpleName());
- }
}
-
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
index b50e7a0ed..74548e724 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
@@ -23,8 +23,6 @@ package org.onap.policy.clamp.controlloop.runtime.main.rest;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
-import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
-import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
@@ -347,15 +345,24 @@ public class CommissioningController extends AbstractRestController {
required = false) String version) {
try {
- return ResponseEntity.ok().body(provider.getToscaServiceTemplate(name, version));
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
+ String response = mapper.writerWithDefaultPrettyPrinter()
+ .writeValueAsString(provider.getToscaServiceTemplate(name, version));
+
+ return ResponseEntity.ok().body(response);
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of tosca service template failed", e);
var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return ResponseEntity.status(e.getErrorResponse().getResponseCode().getStatusCode()).body(resp);
+ } catch (JsonProcessingException e) {
+ LOGGER.warn("Get of tosca service template failed", e);
+ var resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getMessage());
+ return ResponseEntity.status(Status.BAD_REQUEST.getStatusCode()).body(resp);
}
-
}
/**
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
index aba545750..5e94d293e 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
@@ -20,21 +20,46 @@
package org.onap.policy.clamp.controlloop.runtime.supervision;
+import java.time.Instant;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.UUID;
import javax.ws.rs.core.Response;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
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.ParticipantDeregister;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
+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.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.ParticipantDeregisterAckPublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantRegisterAckPublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStateChangePublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusListener;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
+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.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
@@ -60,10 +85,14 @@ public class SupervisionHandler {
private final ControlLoopProvider controlLoopProvider;
private final ParticipantProvider participantProvider;
private final MonitoringProvider monitoringProvider;
+ private final CommissioningProvider commissioningProvider;
// Publishers for participant communication
private final ParticipantControlLoopUpdatePublisher controlLoopUpdatePublisher;
private final ParticipantControlLoopStateChangePublisher controlLoopStateChangePublisher;
+ private final ParticipantRegisterAckPublisher participantRegisterAckPublisher;
+ private final ParticipantDeregisterAckPublisher participantDeregisterAckPublisher;
+ private final ParticipantUpdatePublisher participantUpdatePublisher;
/**
* Supervision trigger called when a command is issued on control loops.
@@ -102,9 +131,8 @@ public class SupervisionHandler {
*
* @param participantStatusMessage the ParticipantStatus message received from a participant
*/
- public void handleParticipantStatusMessage(ParticipantStatus participantStatusMessage) {
+ public void handleParticipantMessage(ParticipantStatus participantStatusMessage) {
LOGGER.debug("Participant Status received {}", participantStatusMessage);
-
try {
superviseParticipant(participantStatusMessage);
} catch (PfModelException | ControlLoopException svExc) {
@@ -120,6 +148,36 @@ public class SupervisionHandler {
}
/**
+ * Handle a ParticipantRegister message from a participant.
+ *
+ * @param participantRegisterMessage the ParticipantRegister message received from a participant
+ */
+ public void handleParticipantMessage(ParticipantRegister participantRegisterMessage) {
+ LOGGER.debug("Participant Register received {}", participantRegisterMessage);
+ sendParticipantAckMessage(participantRegisterMessage);
+ sendParticipantUpdate(participantRegisterMessage);
+ }
+
+ /**
+ * Handle a ParticipantDeregister message from a participant.
+ *
+ * @param participantDeregisterMessage the ParticipantDeregister message received from a participant
+ */
+ public void handleParticipantMessage(ParticipantDeregister participantDeregisterMessage) {
+ LOGGER.debug("Participant Deregister received {}", participantDeregisterMessage);
+ sendParticipantAckMessage(participantDeregisterMessage);
+ }
+
+ /**
+ * Handle a ParticipantUpdateAck message from a participant.
+ *
+ * @param participantUpdateAckMessage the ParticipantUpdateAck message received from a participant
+ */
+ public void handleParticipantMessage(ParticipantUpdateAck participantUpdateAckMessage) {
+ LOGGER.debug("Participant Update Ack received {}", participantUpdateAckMessage);
+ }
+
+ /**
* Supervise a control loop, performing whatever actions need to be performed on the control loop.
*
* @param controlLoop the control loop to supervises
@@ -232,6 +290,70 @@ public class SupervisionHandler {
}
}
+ private void sendControlLoopUpdate(ControlLoop controlLoop) throws PfModelException {
+ var 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
+ pclu.setControlLoopDefinition(commissioningProvider.getToscaServiceTemplate(null, null));
+ controlLoopUpdatePublisher.send(pclu);
+ }
+
+ private void sendControlLoopStateChange(ControlLoop controlLoop) {
+ var clsc = new ParticipantControlLoopStateChange();
+ clsc.setControlLoopId(controlLoop.getKey().asIdentifier());
+ clsc.setMessageId(UUID.randomUUID());
+ clsc.setOrderedState(controlLoop.getOrderedState());
+ controlLoopStateChangePublisher.send(clsc);
+ }
+
+ private void sendParticipantUpdate(ParticipantRegister participantRegisterMessage) {
+ var message = new ParticipantUpdate();
+ message.setParticipantId(participantRegisterMessage.getParticipantId());
+ message.setParticipantType(participantRegisterMessage.getParticipantType());
+ message.setTimestamp(Instant.now());
+
+ ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
+ clDefinition.setId(UUID.randomUUID());
+
+ try {
+ clDefinition.setControlLoopElementToscaServiceTemplate(commissioningProvider
+ .getToscaServiceTemplate(null, null));
+ } catch (PfModelException pfme) {
+ LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme);
+ return;
+ }
+
+ Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap = new LinkedHashMap<>();
+ controlLoopElementDefinitionMap.put(UUID.randomUUID(), clDefinition);
+
+ Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
+ participantDefinitionUpdateMap = new LinkedHashMap<>();
+ participantDefinitionUpdateMap.put(participantRegisterMessage.getParticipantId(),
+ controlLoopElementDefinitionMap);
+ message.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
+
+ LOGGER.debug("Participant Update sent", message);
+ participantUpdatePublisher.send(message);
+ }
+
+ private void sendParticipantAckMessage(ParticipantRegister participantRegisterMessage) {
+ var message = new ParticipantRegisterAck();
+ message.setResponseTo(participantRegisterMessage.getMessageId());
+ message.setMessage("Participant Register Ack");
+ message.setResult(true);
+ participantRegisterAckPublisher.send(message);
+ }
+
+ private void sendParticipantAckMessage(ParticipantDeregister participantDeregisterMessage) {
+ var message = new ParticipantDeregisterAck();
+ message.setResponseTo(participantDeregisterMessage.getMessageId());
+ message.setMessage("Participant Deregister Ack");
+ message.setResult(true);
+ participantDeregisterAckPublisher.send(message);
+ }
+
private void superviseParticipant(ParticipantStatus participantStatusMessage)
throws PfModelException, ControlLoopException {
if (participantStatusMessage.getParticipantId() == null) {
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java
new file mode 100644
index 000000000..4b4ca9915
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/AbstractParticipantAckPublisher.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import java.util.List;
+import javax.ws.rs.core.Response.Status;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantAckMessage;
+import org.onap.policy.clamp.controlloop.runtime.config.messaging.Publisher;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+
+public abstract class AbstractParticipantAckPublisher<E extends ParticipantAckMessage> implements Publisher {
+
+ private TopicSinkClient topicSinkClient;
+ private boolean active = false;
+
+ /**
+ * Method to send Participant message to participants on demand.
+ *
+ * @param participantMessage the Participant message
+ */
+ public void send(final E participantMessage) {
+ if (!active) {
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+ }
+ topicSinkClient.send(participantMessage);
+ }
+
+
+ @Override
+ public void active(List<TopicSink> topicSinks) {
+ if (topicSinks.size() != 1) {
+ throw new IllegalArgumentException("Topic Sink must be one");
+ }
+ this.topicSinkClient = new TopicSinkClient(topicSinks.get(0));
+ active = true;
+ }
+
+ @Override
+ public void stop() {
+ active = false;
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PropertiesConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java
index 04bd35da3..c0fcb3e7d 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PropertiesConfig.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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.
@@ -18,21 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.runtime.config;
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterHandler;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
+import org.springframework.stereotype.Component;
-@Configuration
-public class PropertiesConfig {
+/**
+ * This class is used to send ParticipantDeregisterAck messages to participants on DMaaP.
+ */
+@Component
+public class ParticipantDeregisterAckPublisher extends AbstractParticipantAckPublisher<ParticipantDeregisterAck> {
- @Bean
- public ClRuntimeParameterGroup clRuntimeParameterGroup(@Value("${runtime.file}") String file)
- throws ControlLoopException {
- return new ClRuntimeParameterHandler().getParameters(file);
- }
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java
new file mode 100644
index 000000000..a03ff0a63
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantDeregisterListener.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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.ParticipantDeregister;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * Listener for ParticipantDeregister messages sent by participants.
+ */
+@Component
+public class ParticipantDeregisterListener extends ScoListener<ParticipantDeregister> implements Listener {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantDeregisterListener.class);
+
+ private final SupervisionHandler supervisionHandler;
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantDeregisterListener(SupervisionHandler supervisionHandler) {
+ super(ParticipantDeregister.class);
+ this.supervisionHandler = supervisionHandler;
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantDeregister participantDeregisterMessage) {
+ LOGGER.debug("ParticipantDeregister message received from participant - {}", participantDeregisterMessage);
+ supervisionHandler.handleParticipantMessage(participantDeregisterMessage);
+ }
+
+ @Override
+ public String getType() {
+ return ParticipantMessageType.PARTICIPANT_DEREGISTER.name();
+ }
+
+ @Override
+ public ScoListener<ParticipantDeregister> getScoListener() {
+ return this;
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java
new file mode 100644
index 000000000..2c0c4b393
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterAckPublisher.java
@@ -0,0 +1,32 @@
+/*-
+ * ============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.ParticipantRegisterAck;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is used to send ParticipantRegisterAck messages to participants on DMaaP.
+ */
+@Component
+public class ParticipantRegisterAckPublisher extends AbstractParticipantAckPublisher<ParticipantRegisterAck> {
+
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java
new file mode 100644
index 000000000..a4d8c7697
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantRegisterListener.java
@@ -0,0 +1,67 @@
+/*-
+ * ============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.ParticipantMessageType;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
+import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * Listener for ParticipantRegister messages sent by participants.
+ */
+@Component
+public class ParticipantRegisterListener extends ScoListener<ParticipantRegister> implements Listener {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRegisterListener.class);
+
+ private final SupervisionHandler supervisionHandler;
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantRegisterListener(SupervisionHandler supervisionHandler) {
+ super(ParticipantRegister.class);
+ this.supervisionHandler = supervisionHandler;
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantRegister participantRegisterMessage) {
+ LOGGER.debug("ParticipantRegister message received from participant - {}", participantRegisterMessage);
+ supervisionHandler.handleParticipantMessage(participantRegisterMessage);
+ }
+
+ @Override
+ public String getType() {
+ return ParticipantMessageType.PARTICIPANT_REGISTER.name();
+ }
+
+ @Override
+ public ScoListener<ParticipantRegister> getScoListener() {
+ return this;
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
index 8fa076240..9da886026 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantStatusListener.java
@@ -52,7 +52,7 @@ public class ParticipantStatusListener extends ScoListener<ParticipantStatus> im
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);
+ supervisionHandler.handleParticipantMessage(participantStatusMessage);
}
@Override
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java
new file mode 100644
index 000000000..b8538b1f7
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdateAckListener.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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.ParticipantMessageType;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
+import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.utils.coder.StandardCoderObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * Listener for ParticipantUpdateAck messages sent by participants.
+ */
+@Component
+public class ParticipantUpdateAckListener extends ScoListener<ParticipantUpdateAck> implements Listener {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdateAckListener.class);
+
+ private final SupervisionHandler supervisionHandler;
+
+ /**
+ * Constructs the object.
+ */
+ public ParticipantUpdateAckListener(SupervisionHandler supervisionHandler) {
+ super(ParticipantUpdateAck.class);
+ this.supervisionHandler = supervisionHandler;
+ }
+
+ @Override
+ public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco,
+ final ParticipantUpdateAck participantUpdateAckMessage) {
+ LOGGER.debug("ParticipantUpdateAck message received from participant - {}", participantUpdateAckMessage);
+ supervisionHandler.handleParticipantMessage(participantUpdateAckMessage);
+ }
+
+ @Override
+ public String getType() {
+ return ParticipantMessageType.PARTICIPANT_UPDATE_ACK.name();
+ }
+
+ @Override
+ public ScoListener<ParticipantUpdateAck> getScoListener() {
+ return this;
+ }
+}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
new file mode 100644
index 000000000..5af5f1f54
--- /dev/null
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
@@ -0,0 +1,32 @@
+/*-
+ * ============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.ParticipantUpdate;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is used to send ParticipantUpdate messages to participants on DMaaP.
+ */
+@Component
+public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<ParticipantUpdate> {
+
+}
diff --git a/runtime-controlloop/src/main/resources/application.yaml b/runtime-controlloop/src/main/resources/application.yaml
index af9966d40..3bc2749ed 100644
--- a/runtime-controlloop/src/main/resources/application.yaml
+++ b/runtime-controlloop/src/main/resources/application.yaml
@@ -19,4 +19,33 @@ server:
runtime:
- file: src/main/resources/parameters/ClRuntimeParameters.json
+ supervisionScannerIntervalSec: 1000
+ participantStateChangeIntervalSec: 1000
+ participantClUpdateIntervalSec: 1000
+ participantClStateChangeIntervalSec: 1000
+ 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://${mariadb.host:mariadb}:${mariadb.port:3306}/controlloop
+ databaseUser: policy
+ databasePassword: P01icY
+ persistenceUnit: CommissioningMariaDb
+ topicParameterGroup:
+ topicSources[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks[0]:
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
diff --git a/runtime-controlloop/src/main/resources/parameters/ClRuntimeParameters.json b/runtime-controlloop/src/main/resources/parameters/ClRuntimeParameters.json
deleted file mode 100644
index 00ca7f9a6..000000000
--- a/runtime-controlloop/src/main/resources/parameters/ClRuntimeParameters.json
+++ /dev/null
@@ -1,56 +0,0 @@
-{
- "name": "ControlLoopRuntimeGroup",
- "supervisionScannerIntervalSec": 1000,
- "participantStateChangeIntervalSec": 1000,
- "participantClUpdateIntervalSec": 1000,
- "participantClStateChangeIntervalSec": 1000,
- "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://mariadb:3306/controlloop",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "CommissioningMariaDb"
- },
- "topicParameterGroup": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
-}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
index 440380781..448df4199 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
@@ -31,9 +31,6 @@ import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
-import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.provider.PolicyModelsProvider;
@@ -46,31 +43,11 @@ class CommissioningProviderTest {
private static final String TOSCA_SERVICE_TEMPLATE_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();
- private static int dbNum = 0;
- private static final Object lockit = new Object();
private PolicyModelsProvider modelsProvider = null;
private ControlLoopProvider clProvider = null;
- private static String getParameterGroupAsString() {
- dbNum++;
- return ResourceUtils.getResourceAsString("src/test/resources/parameters/TestParameters.json")
- .replace("jdbc:h2:mem:testdb", "jdbc:h2:mem:commissioningdb" + dbNum);
- }
-
- /**
- * return a Cl Runtime Parameters.
- *
- * @throws CoderException .
- */
- public ClRuntimeParameterGroup getClRuntimeParameterGroup() throws CoderException {
- synchronized (lockit) {
- return CODER.decode(getParameterGroupAsString(), ClRuntimeParameterGroup.class);
- }
- }
-
@AfterEach
void close() throws Exception {
if (modelsProvider != null) {
@@ -88,7 +65,7 @@ class CommissioningProviderTest {
*/
@Test
void testGetControlLoopDefinitions() throws Exception {
- ClRuntimeParameterGroup clRuntimeParameterGroup = getClRuntimeParameterGroup();
+ ClRuntimeParameterGroup clRuntimeParameterGroup = CommonTestData.geParameterGroup("getCLDefinitions");
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
@@ -125,7 +102,7 @@ class CommissioningProviderTest {
*/
@Test
void testCreateControlLoopDefinitions() throws Exception {
- ClRuntimeParameterGroup clRuntimeParameterGroup = getClRuntimeParameterGroup();
+ ClRuntimeParameterGroup clRuntimeParameterGroup = CommonTestData.geParameterGroup("createCLDefinitions");
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
@@ -154,7 +131,7 @@ class CommissioningProviderTest {
*/
@Test
void testDeleteControlLoopDefinitions() throws Exception {
- ClRuntimeParameterGroup clRuntimeParameterGroup = getClRuntimeParameterGroup();
+ ClRuntimeParameterGroup clRuntimeParameterGroup = CommonTestData.geParameterGroup("deleteCLDefinitions");
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
@@ -182,7 +159,7 @@ class CommissioningProviderTest {
*/
@Test
void testGetControlLoopElementDefinitions() throws Exception {
- ClRuntimeParameterGroup clRuntimeParameterGroup = getClRuntimeParameterGroup();
+ ClRuntimeParameterGroup clRuntimeParameterGroup = CommonTestData.geParameterGroup("getCLElDefinitions");
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java
index 2b4abaa3b..461c8b558 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/config/messaging/MessageDispatcherActivatorTest.java
@@ -33,8 +33,8 @@ import static org.mockito.Mockito.when;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterHandler;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantStatusListener;
+import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardCoderObject;
@@ -52,8 +52,7 @@ class MessageDispatcherActivatorTest {
@Test
void testStartAndStop() throws Exception {
- final String path = "src/test/resources/parameters/TestParameters.json";
- ClRuntimeParameterGroup parameterGroup = new ClRuntimeParameterHandler().getParameters(path);
+ ClRuntimeParameterGroup parameterGroup = CommonTestData.geParameterGroup("dbtest");
var publisherFirst = spy(mock(Publisher.class));
var publisherSecond = spy(mock(Publisher.class));
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
index 1d7a00b18..b474b0cdf 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
@@ -45,6 +45,9 @@ import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
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.ParticipantDeregisterAckPublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantRegisterAckPublisher;
+import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProvider;
@@ -97,7 +100,7 @@ class ControlLoopInstantiationProviderTest {
*/
@BeforeAll
public static void setupDbProviderParameters() throws PfModelException {
- ClRuntimeParameterGroup controlLoopParameters = CommonTestData.geParameterGroup(0, "instantproviderdb");
+ ClRuntimeParameterGroup controlLoopParameters = CommonTestData.geParameterGroup("instantproviderdb");
modelsProvider =
CommonTestData.getPolicyModelsProvider(controlLoopParameters.getDatabaseProviderParameters());
@@ -112,8 +115,12 @@ class ControlLoopInstantiationProviderTest {
var participantProvider = new ParticipantProvider(controlLoopParameters.getDatabaseProviderParameters());
var controlLoopUpdatePublisher = Mockito.mock(ParticipantControlLoopUpdatePublisher.class);
var controlLoopStateChangePublisher = Mockito.mock(ParticipantControlLoopStateChangePublisher.class);
+ var participantRegisterAckPublisher = Mockito.mock(ParticipantRegisterAckPublisher.class);
+ var participantDeregisterAckPublisher = Mockito.mock(ParticipantDeregisterAckPublisher.class);
+ var participantUpdatePublisher = Mockito.mock(ParticipantUpdatePublisher.class);
supervisionHandler = new SupervisionHandler(clProvider, participantProvider, monitoringProvider,
- controlLoopUpdatePublisher, controlLoopStateChangePublisher);
+ commissioningProvider, controlLoopUpdatePublisher, controlLoopStateChangePublisher,
+ participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher);
}
@AfterAll
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
index c47211a2d..5f885ec97 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
@@ -97,7 +97,7 @@ class TestMonitoringProvider {
@Test
void testCreateParticipantStatistics() throws Exception {
- ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup(0, "createparStat");
+ ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup("createparStat");
participantStatisticsProvider = new ParticipantStatisticsProvider(parameters.getDatabaseProviderParameters());
clElementStatisticsProvider = new ClElementStatisticsProvider(parameters.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(parameters.getDatabaseProviderParameters());
@@ -123,7 +123,7 @@ class TestMonitoringProvider {
@Test
void testGetParticipantStatistics() throws Exception {
- ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup(0, "getparStat");
+ ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup("getparStat");
participantStatisticsProvider = new ParticipantStatisticsProvider(parameters.getDatabaseProviderParameters());
clElementStatisticsProvider = new ClElementStatisticsProvider(parameters.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(parameters.getDatabaseProviderParameters());
@@ -156,7 +156,7 @@ class TestMonitoringProvider {
@Test
void testCreateClElementStatistics() throws Exception {
- ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup(0, "createelemstat");
+ ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup("createelemstat");
participantStatisticsProvider = new ParticipantStatisticsProvider(parameters.getDatabaseProviderParameters());
clElementStatisticsProvider = new ClElementStatisticsProvider(parameters.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(parameters.getDatabaseProviderParameters());
@@ -183,14 +183,13 @@ class TestMonitoringProvider {
@Test
void testGetClElementStatistics() throws Exception {
- ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup(0, "getelemstat");
+ ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup("getelemstat");
participantStatisticsProvider = new ParticipantStatisticsProvider(parameters.getDatabaseProviderParameters());
clElementStatisticsProvider = new ClElementStatisticsProvider(parameters.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(parameters.getDatabaseProviderParameters());
MonitoringProvider provider =
new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider);
-
assertThatThrownBy(() -> {
provider.fetchFilteredClElementStatistics(null, null, null, null, null, 0);
}).hasMessageMatching("name is marked .*null but is null");
@@ -217,7 +216,7 @@ class TestMonitoringProvider {
@Test
void testGetParticipantStatsPerCL() throws Exception {
- ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup(0, "getparStatCL");
+ ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup("getparStatCL");
participantStatisticsProvider = new ParticipantStatisticsProvider(parameters.getDatabaseProviderParameters());
clElementStatisticsProvider = new ClElementStatisticsProvider(parameters.getDatabaseProviderParameters());
var mockClProvider = Mockito.mock(ControlLoopProvider.class);
@@ -253,7 +252,7 @@ class TestMonitoringProvider {
mockCL.setElements(new LinkedHashMap<>());
mockCL.getElements().put(mockClElement.getId(), mockClElement);
- ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup(0, "getelemstatPerCL");
+ ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup("getelemstatPerCL");
participantStatisticsProvider = new ParticipantStatisticsProvider(parameters.getDatabaseProviderParameters());
clElementStatisticsProvider = new ClElementStatisticsProvider(parameters.getDatabaseProviderParameters());
ControlLoopProvider mockClProvider = Mockito.mock(ControlLoopProvider.class);
@@ -265,8 +264,8 @@ class TestMonitoringProvider {
monitoringProvider.createClElementStatistics(inputClElementStatistics.getClElementStatistics());
- ClElementStatisticsList getResponse;
- getResponse = monitoringProvider.fetchClElementStatsPerControlLoop("testCLName", "1.001");
+ ClElementStatisticsList getResponse =
+ monitoringProvider.fetchClElementStatsPerControlLoop("testCLName", "1.001");
assertThat(getResponse.getClElementStatistics()).hasSize(2);
assertEquals(getResponse.getClElementStatistics().get(1).toString().replaceAll("\\s+", ""),
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
new file mode 100644
index 000000000..305850cbd
--- /dev/null
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -0,0 +1,226 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
+
+import java.time.Instant;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ClElementStatisticsProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantStatisticsProvider;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegisterAck;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
+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.MonitoringProvider;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
+import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+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;
+
+class SupervisionMessagesTest extends CommonRestController {
+
+ private static final String TOSCA_SERVICE_TEMPLATE_YAML =
+ "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
+ private static final Object lockit = new Object();
+ private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
+ private static final String TOPIC = "my-topic";
+ private static final long interval = 1000;
+ private static SupervisionHandler supervisionHandler;
+ private static CommissioningProvider commissioningProvider;
+ private static ControlLoopProvider clProvider;
+ private static PolicyModelsProvider modelsProvider;
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+
+ /**
+ * setup Db Provider Parameters.
+ *
+ * @throws PfModelException if an error occurs
+ */
+ @BeforeAll
+ public static void setupDbProviderParameters() throws PfModelException {
+ ClRuntimeParameterGroup controlLoopParameters = CommonTestData.geParameterGroup("instantproviderdb");
+
+ modelsProvider =
+ CommonTestData.getPolicyModelsProvider(controlLoopParameters.getDatabaseProviderParameters());
+ clProvider = new ControlLoopProvider(controlLoopParameters.getDatabaseProviderParameters());
+ var participantStatisticsProvider =
+ new ParticipantStatisticsProvider(controlLoopParameters.getDatabaseProviderParameters());
+ var clElementStatisticsProvider =
+ new ClElementStatisticsProvider(controlLoopParameters.getDatabaseProviderParameters());
+ commissioningProvider = new CommissioningProvider(modelsProvider, clProvider);
+ var monitoringProvider =
+ new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider);
+ var participantProvider = new ParticipantProvider(controlLoopParameters.getDatabaseProviderParameters());
+ var controlLoopUpdatePublisher = Mockito.mock(ParticipantControlLoopUpdatePublisher.class);
+ var controlLoopStateChangePublisher = Mockito.mock(ParticipantControlLoopStateChangePublisher.class);
+ var participantRegisterAckPublisher = Mockito.mock(ParticipantRegisterAckPublisher.class);
+ var participantDeregisterAckPublisher = Mockito.mock(ParticipantDeregisterAckPublisher.class);
+ var participantUpdatePublisher = Mockito.mock(ParticipantUpdatePublisher.class);
+ supervisionHandler = new SupervisionHandler(clProvider, participantProvider, monitoringProvider,
+ commissioningProvider, controlLoopUpdatePublisher, controlLoopStateChangePublisher,
+ participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher);
+ }
+
+ @AfterAll
+ public static void closeDbProvider() throws PfModelException {
+ clProvider.close();
+ modelsProvider.close();
+ }
+
+ @Test
+ void testReceiveParticipantRegister() throws Exception {
+ final ParticipantRegister participantRegisterMsg = new ParticipantRegister();
+ participantRegisterMsg.setParticipantId(getParticipantId());
+ participantRegisterMsg.setTimestamp(Instant.now());
+ participantRegisterMsg.setParticipantType(getParticipantType());
+
+ synchronized (lockit) {
+ ParticipantRegisterListener participantRegisterListener =
+ new ParticipantRegisterListener(supervisionHandler);
+ ToscaServiceTemplate serviceTemplate = yamlTranslator
+ .fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
+
+ List<ToscaNodeTemplate> listOfTemplates = commissioningProvider.getControlLoopDefinitions(null, null);
+ commissioningProvider.createControlLoopDefinitions(serviceTemplate);
+ participantRegisterListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterMsg);
+ }
+ }
+
+ @Test
+ void testSendParticipantRegisterAck() throws Exception {
+ final ParticipantRegisterAck participantRegisterAckMsg = new ParticipantRegisterAck();
+ participantRegisterAckMsg.setMessage("ParticipantRegisterAck message");
+ participantRegisterAckMsg.setResponseTo(UUID.randomUUID());
+ participantRegisterAckMsg.setResult(true);
+
+ synchronized (lockit) {
+ ParticipantRegisterAckPublisher clRegisterAckPublisher = new ParticipantRegisterAckPublisher();
+ clRegisterAckPublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
+ clRegisterAckPublisher.send(participantRegisterAckMsg);
+ }
+ }
+
+ @Test
+ void testReceiveParticipantDeregister() throws Exception {
+ final ParticipantDeregister participantDeregisterMsg = new ParticipantDeregister();
+ participantDeregisterMsg.setParticipantId(getParticipantId());
+ participantDeregisterMsg.setTimestamp(Instant.now());
+ participantDeregisterMsg.setParticipantType(getParticipantType());
+
+ synchronized (lockit) {
+ ParticipantDeregisterListener participantDeregisterListener =
+ new ParticipantDeregisterListener(supervisionHandler);
+ participantDeregisterListener.onTopicEvent(INFRA, TOPIC, null, participantDeregisterMsg);
+ }
+ }
+
+ @Test
+ void testSendParticipantDeregisterAck() throws Exception {
+ final ParticipantDeregisterAck participantDeregisterAckMsg = new ParticipantDeregisterAck();
+ participantDeregisterAckMsg.setMessage("ParticipantDeregisterAck message");
+ participantDeregisterAckMsg.setResponseTo(UUID.randomUUID());
+ participantDeregisterAckMsg.setResult(true);
+
+ synchronized (lockit) {
+ ParticipantDeregisterAckPublisher clDeregisterAckPublisher = new ParticipantDeregisterAckPublisher();
+ clDeregisterAckPublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
+ clDeregisterAckPublisher.send(participantDeregisterAckMsg);
+ }
+ }
+
+ @Test
+ void testSendParticipantUpdate() throws Exception {
+ final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate();
+ participantUpdateMsg.setParticipantId(getParticipantId());
+ participantUpdateMsg.setTimestamp(Instant.now());
+ participantUpdateMsg.setParticipantType(getParticipantType());
+ participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
+ participantUpdateMsg.setMessageId(UUID.randomUUID());
+
+ ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
+ toscaServiceTemplate.setName("serviceTemplate");
+ toscaServiceTemplate.setDerivedFrom("parentServiceTemplate");
+ toscaServiceTemplate.setDescription("Description of serviceTemplate");
+ toscaServiceTemplate.setVersion("1.2.3");
+
+ ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
+ clDefinition.setId(UUID.randomUUID());
+ clDefinition.setControlLoopElementToscaServiceTemplate(toscaServiceTemplate);
+ Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
+ clDefinition.setCommonPropertiesMap(commonPropertiesMap);
+
+ Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap =
+ Map.of(UUID.randomUUID(), clDefinition);
+
+ Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>>
+ participantDefinitionUpdateMap = Map.of(getParticipantId(), controlLoopElementDefinitionMap);
+ participantUpdateMsg.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap);
+
+ synchronized (lockit) {
+ ParticipantUpdatePublisher clUpdatePublisher = new ParticipantUpdatePublisher();
+ clUpdatePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
+ clUpdatePublisher.send(participantUpdateMsg);
+ }
+ }
+
+ @Test
+ void testReceiveParticipantUpdateAckMessage() throws Exception {
+ final ParticipantUpdateAck participantUpdateAckMsg = new ParticipantUpdateAck();
+ participantUpdateAckMsg.setMessage("ParticipantUpdateAck message");
+ participantUpdateAckMsg.setResponseTo(UUID.randomUUID());
+ participantUpdateAckMsg.setResult(true);
+
+ synchronized (lockit) {
+ ParticipantUpdateAckListener participantUpdateAckListener =
+ new ParticipantUpdateAckListener(supervisionHandler);
+ participantUpdateAckListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateAckMsg);
+ }
+ }
+
+ private ToscaConceptIdentifier getParticipantId() {
+ return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
+ }
+
+ private ToscaConceptIdentifier getParticipantType() {
+ return new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1");
+ }
+}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
index 464c14354..300c662ce 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
@@ -38,19 +38,18 @@ import org.onap.policy.models.provider.PolicyModelsProviderParameters;
*
*/
public class CommonTestData {
- private static final Coder coder = new StandardCoder();
+ private static final Coder CODER = new StandardCoder();
/**
* Gets the standard Control Loop parameters.
*
- * @param port port to be inserted into the parameters
* @param dbName the database name
* @return the standard Control Loop parameters
* @throws ControlLoopRuntimeException on errors reading the control loop parameters
*/
- public static ClRuntimeParameterGroup geParameterGroup(final int port, final String dbName) {
+ public static ClRuntimeParameterGroup geParameterGroup(final String dbName) {
try {
- return coder.decode(getParameterGroupAsString(port, dbName), ClRuntimeParameterGroup.class);
+ return CODER.convert(getParameterGroupAsString(dbName), ClRuntimeParameterGroup.class);
} catch (CoderException e) {
throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "cannot read Control Loop parameters", e);
@@ -60,13 +59,12 @@ public class CommonTestData {
/**
* Gets the standard Control Loop parameters, as a String.
*
- * @param port port to be inserted into the parameters
* @param dbName the database name
* @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/InstantiationConfigParametersStd.json")
- .replace("${port}", String.valueOf(port)).replace("${dbName}", "jdbc:h2:mem:" + dbName);
+ public static String getParameterGroupAsString(final String dbName) {
+ return ResourceUtils.getResourceAsString("src/test/resources/parameters/TestParameters.json")
+ .replace("${dbName}", "jdbc:h2:mem:" + dbName);
}
/**
diff --git a/runtime-controlloop/src/test/resources/application_test.properties b/runtime-controlloop/src/test/resources/application_test.properties
index fc24ea290..e51db25ce 100644
--- a/runtime-controlloop/src/test/resources/application_test.properties
+++ b/runtime-controlloop/src/test/resources/application_test.properties
@@ -6,4 +6,26 @@ server.port=6969
server.servlet.context-path=/onap/controlloop
server.error.path=/error
-runtime.file=src/test/resources/parameters/TestParameters.json
+runtime.supervisionScannerIntervalSec=1000
+runtime.participantStateChangeIntervalSec=1000
+runtime.participantClUpdateIntervalSec=1000
+runtime.participantClStateChangeIntervalSec=1000
+runtime.participantParameters.heartBeatMs=120000
+runtime.participantParameters.updateParameters.maxRetryCount=1
+runtime.participantParameters.updateParameters.maxWaitMs=30000
+runtime.participantParameters.stateChangeParameters.maxRetryCount=1
+runtime.participantParameters.stateChangeParameters.maxWaitMs=30000
+runtime.databaseProviderParameters.name=PolicyProviderParameterGroup
+runtime.databaseProviderParameters.implementation=org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl
+runtime.databaseProviderParameters.databaseDriver=org.h2.Driver
+runtime.databaseProviderParameters.databaseUrl=jdbc:h2:mem:testdb
+runtime.databaseProviderParameters.databaseUser=policy
+runtime.databaseProviderParameters.databasePassword=P01icY
+runtime.databaseProviderParameters.persistenceUnit=ToscaConceptTest
+runtime.topicParameterGroup.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT
+runtime.topicParameterGroup.topicSources[0].servers[0]=localhost
+runtime.topicParameterGroup.topicSources[0].topicCommInfrastructure=dmaap
+runtime.topicParameterGroup.topicSources[0].fetchTimeout=15000
+runtime.topicParameterGroup.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT
+runtime.topicParameterGroup.topicSinks[0].servers[0]=localhost
+runtime.topicParameterGroup.topicSinks[0].topicCommInfrastructure=dmaap
diff --git a/runtime-controlloop/src/test/resources/parameters/CommissioningConfig.json b/runtime-controlloop/src/test/resources/parameters/CommissioningConfig.json
deleted file mode 100644
index 762e3f793..000000000
--- a/runtime-controlloop/src/test/resources/parameters/CommissioningConfig.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "name": "CommissioningGroup",
- "supervisionScannerIntervalSec" : 1000,
- "participantStateChangeIntervalSec" : 1000,
- "participantClUpdateIntervalSec" : 1000,
- "participantClStateChangeIntervalSec" : 1000,
- "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/runtime-controlloop/src/test/resources/parameters/EmptyParameters.json b/runtime-controlloop/src/test/resources/parameters/EmptyParameters.json
deleted file mode 100644
index e69de29bb..000000000
--- a/runtime-controlloop/src/test/resources/parameters/EmptyParameters.json
+++ /dev/null
diff --git a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json
deleted file mode 100644
index 06f4370e8..000000000
--- a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json
+++ /dev/null
@@ -1,63 +0,0 @@
-{
- "name": "ControlLoopRuntimeGroup",
- "supervisionScannerIntervalSec": 1000,
- "participantStateChangeIntervalSec": 1000,
- "participantClUpdateIntervalSec": 1000,
- "participantClStateChangeIntervalSec": 1000,
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": ${port},
- "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.h2.Driver",
- "databaseUrl": "${dbName}",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "InstantiationTests"
- },
- "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"
- }
- ]
- }
-}
diff --git a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json
deleted file mode 100644
index 944bc770d..000000000
--- a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_InvalidName.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "name": " ",
- "supervisionScannerIntervalSec": 1000,
- "participantStateChangeIntervalSec": 1000,
- "participantClUpdateIntervalSec": 1000,
- "participantClStateChangeIntervalSec": 1000,
- "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/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_sim.json b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_sim.json
deleted file mode 100644
index 47cb74838..000000000
--- a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParameters_sim.json
+++ /dev/null
@@ -1,55 +0,0 @@
-{
- "name": "Instantiation",
- "supervisionScannerIntervalSec": 1000,
- "participantStateChangeIntervalSec": 1000,
- "participantClUpdateIntervalSec": 1000,
- "participantClStateChangeIntervalSec": 1000,
- "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/runtime-controlloop/src/test/resources/parameters/InvalidParameters.json b/runtime-controlloop/src/test/resources/parameters/InvalidParameters.json
deleted file mode 100644
index 976ec2937..000000000
--- a/runtime-controlloop/src/test/resources/parameters/InvalidParameters.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name": ""
-}
diff --git a/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json b/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json
deleted file mode 100644
index 2be642943..000000000
--- a/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "PapGroup",
- "supervisionScannerIntervalSec": 1000,
- "participantStateChangeIntervalSec": 1000,
- "participantClUpdateIntervalSec": 1000,
- "participantClStateChangeIntervalSec": 1000,
- "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"
- }
- ]
- }
-}
diff --git a/runtime-controlloop/src/test/resources/parameters/NoParameters.json b/runtime-controlloop/src/test/resources/parameters/NoParameters.json
deleted file mode 100644
index 2c63c0851..000000000
--- a/runtime-controlloop/src/test/resources/parameters/NoParameters.json
+++ /dev/null
@@ -1,2 +0,0 @@
-{
-}
diff --git a/runtime-controlloop/src/test/resources/parameters/TestParameters.json b/runtime-controlloop/src/test/resources/parameters/TestParameters.json
index 680e070f2..07c90d7b2 100644
--- a/runtime-controlloop/src/test/resources/parameters/TestParameters.json
+++ b/runtime-controlloop/src/test/resources/parameters/TestParameters.json
@@ -4,14 +4,6 @@
"participantStateChangeIntervalSec": 1000,
"participantClUpdateIntervalSec": 1000,
"participantClStateChangeIntervalSec": 1000,
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
"participantParameters": {
"heartBeatMs": 120000,
"updateParameters": {
@@ -27,10 +19,10 @@
"name": "PolicyProviderParameterGroup",
"implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
"databaseDriver": "org.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
+ "databaseUrl": "${dbName}",
"databaseUser": "policy",
"databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
+ "persistenceUnit": "InstantiationTests"
},
"topicParameterGroup": {
"topicSources": [
diff --git a/runtime-controlloop/src/test/resources/parameters/Unreadable.json b/runtime-controlloop/src/test/resources/parameters/Unreadable.json
deleted file mode 100644
index 0ea56eb5d..000000000
--- a/runtime-controlloop/src/test/resources/parameters/Unreadable.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "name": "ControlLoopRuntimeGroup",
- "supervisionScannerIntervalSec": 1000,
- "participantStateChangeIntervalSec": 1000,
- "participantClUpdateIntervalSec": 1000,
- "participantClStateChangeIntervalSec": 1000,
- "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.h2.Driver",
- "databaseUrl": "jdbc:h2:mem:testdb",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "ToscaConceptTest"
- },
- "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"
- }
- ]
- }