summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-controlloop/src/main')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/Application.java2
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PropertiesConfig.java38
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java43
-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/resources/application.yaml31
-rw-r--r--runtime-controlloop/src/main/resources/parameters/ClRuntimeParameters.json56
9 files changed, 84 insertions, 225 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/config/PropertiesConfig.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PropertiesConfig.java
deleted file mode 100644
index 04bd35da3..000000000
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/config/PropertiesConfig.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.runtime.config;
-
-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;
-
-@Configuration
-public class PropertiesConfig {
-
- @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/main/parameters/ClRuntimeParameterGroup.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
index 433eeeebb..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,41 +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/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"
- }
- ]
- }
-}