summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormicdzied <michal.1.dziedzic@nokia.com>2019-03-22 12:32:53 +0100
committermicdzied <michal.1.dziedzic@nokia.com>2019-04-08 14:25:04 +0200
commit624618c0d343c707d1a40588c3e226f8db2a2203 (patch)
tree3d0195aaf07bdb1e7a24051c2ac42c1f3ac2528a
parent2abfecad9aeb88ba95d62d718376535fb6e00325 (diff)
use CBS SDK in PRH
-remove unused classes -fix junit tests -use cbs Change-Id: Ibc5841b713ad00522dd78a52b7cb7efa871cb8b4 Issue-ID: DCAEGEN2-1360 Signed-off-by: micdzied <michal.1.dziedzic@nokia.com>
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java6
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java6
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java1
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigFileReader.java78
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfiguration.java (renamed from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java)86
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParser.java (renamed from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParser.java)8
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java85
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java10
-rw-r--r--prh-app-server/src/main/resources/consul_config.json5
-rw-r--r--prh-app-server/src/main/resources/prh_endpoints.json65
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParserTest.java (renamed from prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java)12
-rw-r--r--prh-app-server/src/test/resources/flattened_configuration.json78
12 files changed, 191 insertions, 249 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
index 5ea07e0a..6ce5d64a 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java
@@ -25,6 +25,7 @@ import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.REQUEST_
import java.util.Map;
import java.util.UUID;
+import org.onap.dcaegen2.services.prh.configuration.ConsulConfigFileReader;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationClient;
import org.slf4j.MDC;
import org.springframework.boot.SpringApplication;
@@ -65,4 +66,9 @@ public class MainApp {
CloudConfigurationClient getCloudConfigurationClient(){
return new CloudConfigurationClient();
}
+
+ @Bean
+ ConsulConfigFileReader getConfigFileLoader(){
+ return new ConsulConfigFileReader();
+ }
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
index c90fd9e3..6df9c4ac 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
@@ -42,7 +42,7 @@ import java.util.function.BiFunction;
@Configuration
public class AaiHttpClientConfig {
@Autowired
- private CloudConfiguration cloudConfig;
+ private ConsulConfiguration consulConfiguration;
@Bean
public AaiHttpClient<AaiModel, HttpResponse> getPatchClientFactory() {
@@ -68,8 +68,8 @@ public class AaiHttpClientConfig {
final BiFunction<AaiClientConfiguration, CloudHttpClient, AaiHttpClient<T, U>> factoryMethod) {
return x -> factoryMethod.apply(
- cloudConfig.getAaiClientConfiguration(),
- new AaiHttpClientFactory(cloudConfig.getAaiClientConfiguration()).build()
+ consulConfiguration.getAaiClientConfiguration(),
+ new AaiHttpClientFactory(consulConfiguration.getAaiClientConfiguration()).build()
).getAaiResponse(x);
}
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java
index 21495740..8ac1d9c0 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java
@@ -36,7 +36,6 @@ import org.springframework.context.annotation.Configuration;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
*/
-
@Configuration
@EnableConfigurationProperties
public class AppConfig extends PrhAppConfig {
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigFileReader.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigFileReader.java
new file mode 100644
index 00000000..f11d9ff6
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigFileReader.java
@@ -0,0 +1,78 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PNF-REGISTRATION-HANDLER
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.services.prh.configuration;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.Optional;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableEnvProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.Resource;
+import reactor.core.publisher.Mono;
+
+@Configuration
+public class ConsulConfigFileReader {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConsulConfigFileReader.class);
+ private static final int DEFAULT_CONSUL_PORT = 8500;
+ private ImmutableEnvProperties jsonEnvProperties;
+
+ @Value("classpath:consul_config.json")
+ private Resource consulConfig;
+
+ public Mono<EnvProperties> evaluate() {
+ initFileStreamReader();
+ EnvProperties envProperties = ImmutableEnvProperties.builder()
+ .consulHost(jsonEnvProperties.consulHost())
+ .consulPort(Optional.ofNullable(jsonEnvProperties.consulPort()).orElse(DEFAULT_CONSUL_PORT))
+ .cbsName(jsonEnvProperties.cbsName())
+ .appName(jsonEnvProperties.appName())
+ .build();
+ LOGGER.info("Evaluated variables: {}", envProperties);
+ return Mono.just(envProperties);
+ }
+
+ private void initFileStreamReader() {
+ LOGGER.debug("Loading configuration from configuration file");
+ Gson gson = new Gson();
+ try (InputStream inputStream = consulConfig.getInputStream()) {
+ JsonElement rootElement = getJsonElement(inputStream);
+ if (rootElement.isJsonObject()) {
+ jsonEnvProperties = gson.fromJson(rootElement, ImmutableEnvProperties.class);
+ }
+ } catch (IOException e) {
+ LOGGER.warn("Failed to load/parse file", e);
+ }
+ }
+
+ private JsonElement getJsonElement(InputStream inputStream) {
+ return new JsonParser().parse(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
+ }
+}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfiguration.java
index 10ece50b..3d58f01e 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfiguration.java
@@ -23,97 +23,99 @@ package org.onap.dcaegen2.services.prh.configuration;
import com.google.gson.JsonObject;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.ImmutableAaiClientConfiguration;
-
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFactory;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationClient;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.*;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableScheduling;
import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import java.util.Optional;
-import java.util.Properties;
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/9/18
- */
@Configuration
@ComponentScan("org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers")
@EnableConfigurationProperties
@EnableScheduling
@Primary
-public class CloudConfiguration extends AppConfig {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CloudConfiguration.class);
- private CloudConfigurationClient prhConfigurationProvider;
-
- private AaiClientConfiguration aaiClientCloudConfiguration;
- private DmaapPublisherConfiguration dmaapPublisherCloudConfiguration;
- private DmaapPublisherConfiguration dmaapUpdatePublisherCloudConfiguration;
- private DmaapConsumerConfiguration dmaapConsumerCloudConfiguration;
-
- @Value("#{systemEnvironment}")
- private Properties systemEnvironment;
+public class ConsulConfiguration extends PrhAppConfig {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConsulConfiguration.class);
+ private AaiClientConfiguration aaiClientCBSConfiguration;
+ private DmaapPublisherConfiguration dmaapPublisherCBSConfiguration;
+ private DmaapConsumerConfiguration dmaapConsumerCBSConfiguration;
+ private DmaapPublisherConfiguration dmaapUpdatePublisherCBSConfiguration;
@Autowired
- public void setThreadPoolTaskScheduler(CloudConfigurationClient prhConfigurationProvider) {
- this.prhConfigurationProvider = prhConfigurationProvider;
- }
+ private ConsulConfigFileReader consulConfigFileReader;
public void runTask() {
- Flux.defer(() -> EnvironmentProcessor.evaluate(systemEnvironment))
+ Flux.defer(this::resolveEnvProperties)
.subscribeOn(Schedulers.parallel())
.subscribe(this::parsingConfigSuccess, this::parsingConfigError);
}
- private void parsingConfigError(Throwable throwable) {
- LOGGER.warn("Failed to process system environments", throwable);
- }
-
- private void cloudConfigError(Throwable throwable) {
- LOGGER.warn("Failed to gather configuration from ConfigBindingService/Consul", throwable);
+ private Mono<EnvProperties> resolveEnvProperties() {
+ try {
+ return Mono.just(EnvProperties.fromEnvironment());
+ } catch(Exception e){
+ parsingConfigError(e);
+ return consulConfigFileReader.evaluate();
+ }
}
private void parsingConfigSuccess(EnvProperties envProperties) {
- LOGGER.debug("Fetching PRH configuration from ConfigBindingService/Consul");
- prhConfigurationProvider.callForServiceConfigurationReactive(envProperties)
- .subscribe(this::parseCloudConfig, this::cloudConfigError);
+ LOGGER.debug("Fetching PRH configuration from Consul");
+ CbsClientFactory.createCbsClient(envProperties)
+ .flatMap(cbsClient -> cbsClient.get(CbsRequests.getAll(RequestDiagnosticContext.create())))
+ .subscribe(this::parseCBSConfig, this::cbsConfigError);
}
- private void parseCloudConfig(JsonObject jsonObject) {
+ private void parseCBSConfig(JsonObject jsonObject) {
LOGGER.info("Received application configuration: {}", jsonObject);
- CloudConfigParser cloudConfigParser = new CloudConfigParser(jsonObject);
- dmaapPublisherCloudConfiguration = cloudConfigParser.getDmaapPublisherConfig();
- dmaapUpdatePublisherCloudConfiguration = cloudConfigParser.getDmaapUpdatePublisherConfig();
- aaiClientCloudConfiguration = ImmutableAaiClientConfiguration.copyOf(cloudConfigParser.getAaiClientConfig())
+ ConsulConfigurationParser consulConfigurationParser = new ConsulConfigurationParser(jsonObject);
+ dmaapPublisherCBSConfiguration = consulConfigurationParser.getDmaapPublisherConfig();
+ dmaapUpdatePublisherCBSConfiguration = consulConfigurationParser.getDmaapUpdatePublisherConfig();
+ aaiClientCBSConfiguration = ImmutableAaiClientConfiguration.copyOf(consulConfigurationParser.getAaiClientConfig())
.withAaiHeaders(aaiClientConfiguration.aaiHeaders());
- dmaapConsumerCloudConfiguration = cloudConfigParser.getDmaapConsumerConfig();
+ dmaapConsumerCBSConfiguration = consulConfigurationParser.getDmaapConsumerConfig();
+ }
+
+ private void parsingConfigError(Throwable throwable) {
+ LOGGER.warn("Failed to process system environments", throwable);
+ }
+
+ private void cbsConfigError(Throwable throwable) {
+ LOGGER.warn("Failed to gather configuration from ConfigBindingService/Consul", throwable);
}
@Override
public DmaapPublisherConfiguration getDmaapPublisherConfiguration() {
- return Optional.ofNullable(dmaapPublisherCloudConfiguration).orElse(super.getDmaapPublisherConfiguration());
+ return Optional.ofNullable(dmaapPublisherCBSConfiguration).orElse(super.getDmaapPublisherConfiguration());
}
@Override
public DmaapPublisherConfiguration getDmaapUpdatePublisherConfiguration() {
- return Optional.ofNullable(dmaapUpdatePublisherCloudConfiguration).orElse(super.getDmaapPublisherConfiguration());
+ return Optional.ofNullable(dmaapUpdatePublisherCBSConfiguration).orElse(super.getDmaapPublisherConfiguration());
}
@Override
public AaiClientConfiguration getAaiClientConfiguration() {
- return Optional.ofNullable(aaiClientCloudConfiguration).orElse(super.getAaiClientConfiguration());
+ return Optional.ofNullable(aaiClientCBSConfiguration).orElse(super.getAaiClientConfiguration());
}
@Override
public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
- return Optional.ofNullable(dmaapConsumerCloudConfiguration).orElse(super.getDmaapConsumerConfiguration());
+ return Optional.ofNullable(dmaapConsumerCBSConfiguration).orElse(super.getDmaapConsumerConfiguration());
}
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParser.java
index ec01ff50..b05c0324 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParser.java
@@ -31,16 +31,16 @@ import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.Immutabl
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/21/18
*/
-class CloudConfigParser {
-
+class ConsulConfigurationParser {
private static final String SECURITY_TRUST_STORE_PATH = "security.trustStorePath";
private static final String SECURITY_TRUST_STORE_PASS_PATH = "security.trustStorePasswordPath";
private static final String SECURITY_KEY_STORE_PATH = "security.keyStorePath";
private static final String SECURITY_KEY_STORE_PASS_PATH = "security.keyStorePasswordPath";
+ private static final String CONFIG = "config";
private final JsonObject jsonObject;
- CloudConfigParser(JsonObject jsonObject) {
- this.jsonObject = jsonObject;
+ ConsulConfigurationParser(JsonObject jsonObject) {
+ this.jsonObject = jsonObject.getAsJsonObject(CONFIG);
}
DmaapPublisherConfiguration getDmaapPublisherConfig() {
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java
deleted file mode 100644
index 3d765bde..00000000
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcaegen2.services.prh.configuration;
-
-import org.onap.dcaegen2.services.prh.exceptions.EnvironmentLoaderException;
-import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties;
-import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableEnvProperties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import reactor.core.publisher.Mono;
-
-import java.util.Optional;
-import java.util.Properties;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/10/18
- */
-final class EnvironmentProcessor {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(EnvironmentProcessor.class);
- private static final int DEFAULT_CONSUL_PORT = 8500;
-
- private EnvironmentProcessor() {
- }
-
- static Mono<EnvProperties> evaluate(Properties systemEnvironment) {
- LOGGER.debug("Loading configuration from system environment variables");
- EnvProperties envProperties;
- try {
- envProperties = ImmutableEnvProperties.builder().consulHost(getConsulHost(systemEnvironment))
- .consulPort(getConsultPort(systemEnvironment)).cbsName(getConfigBindingService(systemEnvironment))
- .appName(getService(systemEnvironment)).build();
- } catch (EnvironmentLoaderException e) {
- return Mono.error(e);
- }
- LOGGER.info("Evaluated system environment variables: {}", envProperties);
- return Mono.just(envProperties);
- }
-
- private static String getConsulHost(Properties systemEnvironments) throws EnvironmentLoaderException {
- return Optional.ofNullable(systemEnvironments.getProperty("CONSUL_HOST"))
- .orElseThrow(() -> new EnvironmentLoaderException("$CONSUL_HOST environment has not been defined"));
- }
-
- private static Integer getConsultPort(Properties systemEnvironments) {
- return Optional.ofNullable(systemEnvironments.getProperty("CONSUL_PORT")).map(Integer::valueOf)
- .orElseGet(EnvironmentProcessor::getDefaultPortOfConsul);
- }
-
- private static String getConfigBindingService(Properties systemEnvironments) throws EnvironmentLoaderException {
- return Optional.ofNullable(systemEnvironments.getProperty("CONFIG_BINDING_SERVICE"))
- .orElseThrow(
- () -> new EnvironmentLoaderException("$CONFIG_BINDING_SERVICE environment has not been defined"));
- }
-
- private static String getService(Properties systemEnvironments) throws EnvironmentLoaderException {
- return Optional.ofNullable(Optional.ofNullable(systemEnvironments.getProperty("HOSTNAME"))
- .orElse(systemEnvironments.getProperty("SERVICE_NAME")))
- .orElseThrow(() -> new EnvironmentLoaderException(
- "Neither $HOSTNAME/$SERVICE_NAME have not been defined as system environment"));
- }
-
- private static Integer getDefaultPortOfConsul() {
- LOGGER.warn("$CONSUL_PORT environment has not been defined, using default port: {}", DEFAULT_CONSUL_PORT);
- return DEFAULT_CONSUL_PORT;
- }
-}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
index 956ffead..e20e25d8 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
@@ -28,7 +28,7 @@ import java.util.List;
import java.util.concurrent.ScheduledFuture;
import javax.annotation.PostConstruct;
-import org.onap.dcaegen2.services.prh.configuration.CloudConfiguration;
+import org.onap.dcaegen2.services.prh.configuration.ConsulConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
@@ -57,15 +57,15 @@ public class ScheduledTasksRunner {
private final TaskScheduler taskScheduler;
private final ScheduledTasks scheduledTask;
- private final CloudConfiguration cloudConfiguration;
+ private final ConsulConfiguration consulConfiguration;
@Autowired
public ScheduledTasksRunner(TaskScheduler taskScheduler,
ScheduledTasks scheduledTask,
- CloudConfiguration cloudConfiguration) {
+ ConsulConfiguration consulConfiguration) {
this.taskScheduler = taskScheduler;
this.scheduledTask = scheduledTask;
- this.cloudConfiguration = cloudConfiguration;
+ this.consulConfiguration = consulConfiguration;
}
/**
@@ -94,7 +94,7 @@ public class ScheduledTasksRunner {
LOGGER.info(ENTRY, "Start scheduling PRH workflow");
if (scheduledPrhTaskFutureList.isEmpty()) {
scheduledPrhTaskFutureList.add(taskScheduler
- .scheduleAtFixedRate(cloudConfiguration::runTask, Instant.now(),
+ .scheduleAtFixedRate(consulConfiguration::runTask, Instant.now(),
Duration.ofMinutes(SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY)));
scheduledPrhTaskFutureList.add(taskScheduler
.scheduleWithFixedDelay(scheduledTask::scheduleMainPrhEventTask,
diff --git a/prh-app-server/src/main/resources/consul_config.json b/prh-app-server/src/main/resources/consul_config.json
new file mode 100644
index 00000000..7cefd641
--- /dev/null
+++ b/prh-app-server/src/main/resources/consul_config.json
@@ -0,0 +1,5 @@
+{
+ "consulHost": "10.42.111.9",
+ "cbsName": "cbs",
+ "appName": "dcae-prh"
+} \ No newline at end of file
diff --git a/prh-app-server/src/main/resources/prh_endpoints.json b/prh-app-server/src/main/resources/prh_endpoints.json
deleted file mode 100644
index a24dfd92..00000000
--- a/prh-app-server/src/main/resources/prh_endpoints.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "configs": {
- "dmaap": {
- "dmaapConsumerConfiguration": {
- "dmaapHostName": "localhost",
- "dmaapPortNumber": 8904,
- "dmaapTopicName": "events/unauthenticated.VES_PNFREG_OUTPUT",
- "dmaapProtocol": "http",
- "dmaapUserName": "admin",
- "dmaapUserPassword": "admin",
- "dmaapContentType": "application/json",
- "consumerId": "c12",
- "consumerGroup": "OpenDcae-c12",
- "timeoutMs": -1,
- "messageLimit": 1
- },
- "dmaapProducerConfiguration": {
- "dmaapHostName": "localhost",
- "dmaapPortNumber": 8904,
- "dmaapTopicName": "events/unauthenticated.PNF_READY",
- "dmaapProtocol": "http",
- "dmaapUserName": "admin",
- "dmaapUserPassword": "admin",
- "dmaapContentType": "application/json"
- },
- "dmaapUpdateProducerConfiguration": {
- "dmaapHostName": "localhost",
- "dmaapPortNumber": 8904,
- "dmaapTopicName": "events/unauthenticated.PNF_UPDATE",
- "dmaapProtocol": "http",
- "dmaapUserName": "admin",
- "dmaapUserPassword": "admin",
- "dmaapContentType": "application/json"
- }
- },
- "aai": {
- "aaiClientConfiguration": {
- "aaiHost": "localhost",
- "aaiPort": 8443,
- "aaiProtocol": "https",
- "aaiUserName": "AAI",
- "aaiUserPassword": "AAI",
- "aaiIgnoreSslCertificateErrors": true,
- "aaiBasePath": "/aai/v12",
- "aaiPnfPath": "/network/pnfs/pnf",
- "aaiServiceInstancePath": "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}",
- "aaiHeaders": {
- "X-FromAppId": "prh",
- "X-TransactionId": "9999",
- "Accept": "application/json",
- "Real-Time": "true",
- "Authorization": "Basic QUFJOkFBSQ=="
- }
- }
- },
- "security": {
- "trustStorePath" : "change it",
- "trustStorePasswordPath" : "change it",
- "keyStorePath" : "change it",
- "keyStorePasswordPath" : "change it",
- "enableAaiCertAuth" : "false",
- "enableDmaapCertAuth" : "false"
- }
- }
-} \ No newline at end of file
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParserTest.java
index 8f421034..3c746940 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParserTest.java
@@ -37,7 +37,7 @@ import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.Immutabl
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration;
-class CloudConfigParserTest {
+class ConsulConfigurationParserTest {
private final String correctJson =
new String(Files.readAllBytes(Paths.get(getSystemResource("flattened_configuration.json").toURI())));
@@ -47,16 +47,16 @@ class CloudConfigParserTest {
TestAppConfiguration.createDefaultDmaapConsumerConfiguration();
private final ImmutableDmaapPublisherConfiguration correctDmaapPublisherConfig =
TestAppConfiguration.createDefaultDmaapPublisherConfiguration();
- private final CloudConfigParser cloudConfigParser = new CloudConfigParser(
+ private final ConsulConfigurationParser consulConfigurationParser = new ConsulConfigurationParser(
new Gson().fromJson(correctJson, JsonObject.class));
- CloudConfigParserTest() throws Exception {
+ ConsulConfigurationParserTest() throws Exception {
}
@Test
void shouldCreateAaiConfigurationCorrectly() {
// when
- AaiClientConfiguration aaiClientConfig = cloudConfigParser.getAaiClientConfig();
+ AaiClientConfiguration aaiClientConfig = consulConfigurationParser.getAaiClientConfig();
// then
assertThat(aaiClientConfig).isNotNull();
@@ -67,7 +67,7 @@ class CloudConfigParserTest {
@Test
void shouldCreateDmaapConsumerConfigurationCorrectly() {
// when
- DmaapConsumerConfiguration dmaapConsumerConfig = cloudConfigParser.getDmaapConsumerConfig();
+ DmaapConsumerConfiguration dmaapConsumerConfig = consulConfigurationParser.getDmaapConsumerConfig();
// then
assertThat(dmaapConsumerConfig).isNotNull();
@@ -78,7 +78,7 @@ class CloudConfigParserTest {
@Test
void shouldCreateDmaapPublisherConfigurationCorrectly() {
// when
- DmaapPublisherConfiguration dmaapPublisherConfig = cloudConfigParser.getDmaapPublisherConfig();
+ DmaapPublisherConfiguration dmaapPublisherConfig = consulConfigurationParser.getDmaapPublisherConfig();
// then
assertThat(dmaapPublisherConfig).isNotNull();
diff --git a/prh-app-server/src/test/resources/flattened_configuration.json b/prh-app-server/src/test/resources/flattened_configuration.json
index 3c1cc9ac..48b45a80 100644
--- a/prh-app-server/src/test/resources/flattened_configuration.json
+++ b/prh-app-server/src/test/resources/flattened_configuration.json
@@ -1,40 +1,42 @@
{
- "aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors": true,
- "dmaap.dmaapProducerConfiguration.dmaapTopicName": "/events/unauthenticated.PNF_READY",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName": "/events/unauthenticated.PNF_UPDATE",
- "dmaap.dmaapConsumerConfiguration.timeoutMs": -1,
- "dmaap.dmaapConsumerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local",
- "aai.aaiClientConfiguration.pnfUrl": "https://aai.onap.svc.cluster.local:8443/aai/v12/network/pnfs/pnf",
- "aai.aaiClientConfiguration.aaiPnfPath": "/network/pnfs/pnf",
- "aai.aaiClientConfiguration.aaiServiceInstancePath": "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}",
- "aai.aaiClientConfiguration.aaiUserPassword": "AAI",
- "dmaap.dmaapConsumerConfiguration.dmaapUserName": "admin",
- "aai.aaiClientConfiguration.aaiBasePath": "/aai/v12",
- "dmaap.dmaapProducerConfiguration.dmaapPortNumber": 3904,
- "aai.aaiClientConfiguration.aaiHost": "aai.onap.svc.cluster.local",
- "dmaap.dmaapConsumerConfiguration.dmaapUserPassword": "admin",
- "dmaap.dmaapProducerConfiguration.dmaapProtocol": "http",
- "dmaap.dmaapProducerConfiguration.dmaapContentType": "application/json",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol": "http",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapContentType": "application/json",
- "dmaap.dmaapConsumerConfiguration.dmaapTopicName": "/events/unauthenticated.SEC_OTHER_OUTPUT",
- "dmaap.dmaapConsumerConfiguration.dmaapPortNumber": 3904,
- "dmaap.dmaapConsumerConfiguration.dmaapContentType": "application/json",
- "dmaap.dmaapConsumerConfiguration.messageLimit": -1,
- "dmaap.dmaapConsumerConfiguration.dmaapProtocol": "http",
- "aai.aaiClientConfiguration.aaiUserName": "AAI",
- "dmaap.dmaapConsumerConfiguration.consumerId": "c12",
- "dmaap.dmaapProducerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local",
- "aai.aaiClientConfiguration.aaiHostPortNumber": 8443,
- "dmaap.dmaapConsumerConfiguration.consumerGroup": "OpenDCAE-c12",
- "aai.aaiClientConfiguration.aaiProtocol": "https",
- "dmaap.dmaapProducerConfiguration.dmaapUserName": "admin",
- "dmaap.dmaapProducerConfiguration.dmaapUserPassword": "admin",
- "security.trustStorePath": "/opt/app/prh/local/org.onap.prh.trust.jks",
- "security.trustStorePasswordPath": "change_it",
- "security.keyStorePath": "/opt/app/prh/local/org.onap.prh.p12",
- "security.keyStorePasswordPath": "change_it",
- "security.enableAaiCertAuth": false,
- "security.enableDmaapCertAuth": false
+ "config": {
+ "aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors": true,
+ "dmaap.dmaapProducerConfiguration.dmaapTopicName": "/events/unauthenticated.PNF_READY",
+ "dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName": "/events/unauthenticated.PNF_UPDATE",
+ "dmaap.dmaapConsumerConfiguration.timeoutMs": -1,
+ "dmaap.dmaapConsumerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local",
+ "aai.aaiClientConfiguration.pnfUrl": "https://aai.onap.svc.cluster.local:8443/aai/v12/network/pnfs/pnf",
+ "aai.aaiClientConfiguration.aaiPnfPath": "/network/pnfs/pnf",
+ "aai.aaiClientConfiguration.aaiServiceInstancePath": "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}",
+ "aai.aaiClientConfiguration.aaiUserPassword": "AAI",
+ "dmaap.dmaapConsumerConfiguration.dmaapUserName": "admin",
+ "aai.aaiClientConfiguration.aaiBasePath": "/aai/v12",
+ "dmaap.dmaapProducerConfiguration.dmaapPortNumber": 3904,
+ "aai.aaiClientConfiguration.aaiHost": "aai.onap.svc.cluster.local",
+ "dmaap.dmaapConsumerConfiguration.dmaapUserPassword": "admin",
+ "dmaap.dmaapProducerConfiguration.dmaapProtocol": "http",
+ "dmaap.dmaapProducerConfiguration.dmaapContentType": "application/json",
+ "dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol": "http",
+ "dmaap.dmaapUpdateProducerConfiguration.dmaapContentType": "application/json",
+ "dmaap.dmaapConsumerConfiguration.dmaapTopicName": "/events/unauthenticated.SEC_OTHER_OUTPUT",
+ "dmaap.dmaapConsumerConfiguration.dmaapPortNumber": 3904,
+ "dmaap.dmaapConsumerConfiguration.dmaapContentType": "application/json",
+ "dmaap.dmaapConsumerConfiguration.messageLimit": -1,
+ "dmaap.dmaapConsumerConfiguration.dmaapProtocol": "http",
+ "aai.aaiClientConfiguration.aaiUserName": "AAI",
+ "dmaap.dmaapConsumerConfiguration.consumerId": "c12",
+ "dmaap.dmaapProducerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local",
+ "dmaap.dmaapUpdateProducerConfiguration.dmaapHostName": "message-router.onap.svc.cluster.local",
+ "aai.aaiClientConfiguration.aaiHostPortNumber": 8443,
+ "dmaap.dmaapConsumerConfiguration.consumerGroup": "OpenDCAE-c12",
+ "aai.aaiClientConfiguration.aaiProtocol": "https",
+ "dmaap.dmaapProducerConfiguration.dmaapUserName": "admin",
+ "dmaap.dmaapProducerConfiguration.dmaapUserPassword": "admin",
+ "security.trustStorePath": "/opt/app/prh/local/org.onap.prh.trust.jks",
+ "security.trustStorePasswordPath": "change_it",
+ "security.keyStorePath": "/opt/app/prh/local/org.onap.prh.p12",
+ "security.keyStorePasswordPath": "change_it",
+ "security.enableAaiCertAuth": false,
+ "security.enableDmaapCertAuth": false
+ }
} \ No newline at end of file