summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-kubernetes/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes/src/main')
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java4
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParametersConfig.java41
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameterHandler.java73
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java34
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java3
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json56
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml27
7 files changed, 43 insertions, 195 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java
index ffa0bceb9..37ecf4e6f 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java
@@ -22,19 +22,21 @@ package org.onap.policy.clamp.controlloop.participant.kubernetes;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
/**
* Starter.
*
*/
@SpringBootApplication
+@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.kubernetes.parameters")
public class Application {
/**
* Main class.
+ *
* @param args args
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
-
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParametersConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParametersConfig.java
deleted file mode 100644
index 5f2a4e4ad..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParametersConfig.java
+++ /dev/null
@@ -1,41 +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.participant.kubernetes.configurations;
-
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
-import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.ParticipantK8sParameterHandler;
-import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.ParticipantK8sParameters;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class ParametersConfig {
-
- @Value("${participant.file}")
- private String file;
-
- @Bean
- public ParticipantK8sParameters participantK8sParameters() throws ControlLoopException {
- return new ParticipantK8sParameterHandler().toParticipantK8sParameters(file);
- }
-}
-
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameterHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameterHandler.java
deleted file mode 100644
index 1a7dc35e8..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameterHandler.java
+++ /dev/null
@@ -1,73 +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.participant.kubernetes.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.BeanValidationResult;
-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 participant parameters from JSON files.
- */
-public class ParticipantK8sParameterHandler {
- private static final Coder CODER = new StandardCoder();
-
- /**
- * Read the parameters from the path of the file.
- *
- * @param path path of the config file.
- * @return the parameters read from the configuration file
- * @throws ControlLoopException on parameter exceptions
- */
- public ParticipantK8sParameters toParticipantK8sParameters(String path) throws ControlLoopException {
- ParticipantK8sParameters parameters = null;
- // Read the parameters
- try {
- // Read the parameters from JSON
- var file = new File(path);
- parameters = CODER.decode(file, ParticipantK8sParameters.class);
- } catch (final CoderException e) {
- final String errorMessage =
- "error reading parameters from \"" + path + "\"\n" + "(" + e.getClass().getSimpleName() + ")";
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage, e);
- }
-
- // The JSON processing returns null if there is an empty file
- if (parameters == null) {
- final String errorMessage = "no parameters found in \"" + path + "\"";
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, errorMessage);
- }
-
- // validate the parameters
- final BeanValidationResult validationResult = parameters.validate();
- if (!validationResult.isValid()) {
- String returnMessage =
- "validation error(s) on parameters from \"" + path + "\"\n" + validationResult.getResult();
- throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, returnMessage);
- }
-
- return parameters;
- }
-}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java
index 65b32433c..54eb3b225 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java
@@ -21,39 +21,31 @@
package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters;
import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
-import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.parameters.annotations.Valid;
-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 kubernetes participant.
*
*/
-@NotNull
-@NotBlank
+@Validated
@Getter
-public class ParticipantK8sParameters extends ParameterGroupImpl {
- public static final String DEFAULT_LOCAL_CHART_DIR = "/var/helm-manager/local-charts";
- public static final String DEFAULT_INFO_FILE_NAME = "CHART_INFO.json";
+@Setter
+@ConfigurationProperties(prefix = "participant")
+public class ParticipantK8sParameters {
+ @NotNull
@Valid
private ParticipantIntermediaryParameters intermediaryParameters;
- @Valid
- private PolicyModelsProviderParameters databaseProviderParameters;
-
- private String localChartDirectory = DEFAULT_LOCAL_CHART_DIR;
- private String infoFileName = DEFAULT_INFO_FILE_NAME;
+ @NotBlank
+ private String localChartDirectory;
- /**
- * Create the kubernetes participant parameter group.
- *
- * @param name the parameter group name
- */
- public ParticipantK8sParameters(final String name) {
- super(name);
- }
+ @NotBlank
+ private String infoFileName;
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
index e7458a4cd..dcdff62f5 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
@@ -40,7 +40,6 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.FileSystemUtils;
import org.springframework.web.multipart.MultipartFile;
@@ -61,7 +60,7 @@ public class ChartStore {
/**
* Constructor method.
*/
- public ChartStore(@Autowired ParticipantK8sParameters participantK8sParameters) {
+ public ChartStore(ParticipantK8sParameters participantK8sParameters) {
this.participantK8sParameters = participantK8sParameters;
this.restoreFromLocalFileSystem();
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json
deleted file mode 100644
index e854a9375..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json
+++ /dev/null
@@ -1,56 +0,0 @@
-{
- "name": "ControlLoopParticipantK8s",
- "localChartDirectory": "/var/helm-manager/local-charts",
- "infoFileName": "CHART_INFO.json",
-
- "intermediaryParameters":{
- "name":"Participant parameters",
- "reportingTimeInterval":120000,
- "description":"Participant Description",
- "participantId":{
- "name":"K8sParticipant0",
- "version":"1.0.0"
- },
- "participantType":{
- "name":"org.onap.k8s.controlloop.K8SControlLoopParticipant",
- "version":"2.3.4"
- },
- "clampControlLoopTopics":{
- "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"
- }
- ]
- }
- },
- "databaseProviderParameters":{
- "name":"PolicyProviderParameterGroup",
- "implementation":"org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver":"org.mariadb.jdbc.Driver",
- "databaseUrl":"jdbc:mariadb://localhost:3306/controlloop",
- "databaseUser":"policy",
- "databasePassword":"P01icY",
- "persistenceUnit":"ToscaConceptTest"
- }
-}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
index b4240036b..63ec8a295 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
@@ -3,7 +3,32 @@ spring:
active: prod
participant:
- file: src/main/resources/config/KubernetesParticipantConfig.json
+ localChartDirectory: /var/helm-manager/local-charts
+ infoFileName: CHART_INFO.json
+ intermediaryParameters:
+ reportingTimeInterval: 120000
+ description: Participant Description
+ participantId:
+ name: K8sParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.k8s.controlloop.K8SControlLoopParticipant
+ version: 2.3.4
+ clampControlLoopTopics:
+ 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
+ topicSinks[1]:
+ topic: POLICY-NOTIFICATION
+ servers[0]: ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+
management:
endpoints:
web: