aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-08-10 13:43:10 +0200
committerwasala <przemyslaw.wasala@nokia.com>2018-08-21 14:50:35 +0200
commite625d742db0cf04038081aac0758396eb3961977 (patch)
treeeb48f3ffa276fafe381e60d697400b54b6e7af8c
parent062d6042a235f96d7298a322495691ca8919fc54 (diff)
Downloading prhConf fromConsul
*Added backGround task for downloading dynamic Configuration from Consul *This configuration can pass for Kubernetes and heat (bare metal) deployment *Parsing/validation configuration from system environment Change-Id: I937cbda1bc8b715dc3e754bea8a39dd141180e49 Issue-ID: DCAEGEN2-696 Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
-rw-r--r--prh-app-server/config/application.yaml2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java13
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java3
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.java78
-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/configuration/SchedulerConfig.java36
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java31
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/EnvProperties.java43
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpClientExecutorService.java47
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java10
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java13
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java10
12 files changed, 340 insertions, 31 deletions
diff --git a/prh-app-server/config/application.yaml b/prh-app-server/config/application.yaml
index 4c8c3ef1..706532d7 100644
--- a/prh-app-server/config/application.yaml
+++ b/prh-app-server/config/application.yaml
@@ -19,4 +19,4 @@ logging:
org.onap.dcaegen2.services.prh: INFO
file: opt/log/application.log
app:
- filepath: config/prh_endpoints.json
+ filepath: config/prh_endpoints.json \ No newline at end of file
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 21dcf81e..5fe7c60e 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
@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
@@ -46,7 +47,17 @@ public class MainApp {
}
@Bean
- TaskScheduler taskScheduler() {
+ ConcurrentTaskScheduler concurrentTaskScheduler() {
return new ConcurrentTaskScheduler();
}
+
+ @Bean
+ ThreadPoolTaskScheduler threadPoolTaskScheduler() {
+ ThreadPoolTaskScheduler threadPoolTaskScheduler
+ = new ThreadPoolTaskScheduler();
+ threadPoolTaskScheduler.setPoolSize(5);
+ threadPoolTaskScheduler.setThreadNamePrefix(
+ "CloudThreadPoolTaskScheduler");
+ return threadPoolTaskScheduler;
+ }
}
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 c1000fe9..d83c8138 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
@@ -30,6 +30,7 @@ import org.onap.dcaegen2.services.prh.config.ImmutableAaiClientConfiguration;
import org.onap.dcaegen2.services.prh.config.ImmutableDmaapConsumerConfiguration;
import org.onap.dcaegen2.services.prh.config.ImmutableDmaapPublisherConfiguration;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@@ -38,8 +39,8 @@ import org.springframework.stereotype.Component;
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
*/
-@Component
@Configuration
+@EnableConfigurationProperties
public class AppConfig extends PrhAppConfig {
private static Predicate<String> isEmpty = String::isEmpty;
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/CloudConfiguration.java
new file mode 100644
index 00000000..5b5c038b
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfiguration.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 java.util.Properties;
+import org.onap.dcaegen2.services.prh.model.EnvProperties;
+import org.onap.dcaegen2.services.prh.service.HttpClientExecutorService;
+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.Configuration;
+import org.springframework.scheduling.TaskScheduler;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
+import reactor.core.publisher.Flux;
+import reactor.core.scheduler.Schedulers;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/9/18
+ */
+@Configuration
+@EnableConfigurationProperties
+@EnableScheduling
+public class CloudConfiguration extends AppConfig {
+
+ private Logger logger = LoggerFactory.getLogger(this.getClass());
+ private HttpClientExecutorService httpClientExecutorService;
+
+ TaskScheduler cloudTaskScheduler;
+
+ @Value("#{systemEnvironment}")
+ private Properties systemEnvironment;
+
+
+ @Autowired
+ public void setThreadPoolTaskScheduler(ThreadPoolTaskScheduler threadPoolTaskScheduler,
+ HttpClientExecutorService httpClientExecutorService) {
+ this.cloudTaskScheduler = threadPoolTaskScheduler;
+ this.httpClientExecutorService = httpClientExecutorService;
+ }
+
+ protected void runTask() {
+ Flux.defer(() -> EnvironmentProcessor.evaluate(systemEnvironment))
+ .subscribeOn(Schedulers.parallel())
+ .subscribe(this::doOnSucces, this::doOnError);
+ }
+
+ private void doOnError(Throwable throwable) {
+ logger.warn("Error in case of processing system environment.%nMore details below:%n ", throwable);
+ }
+
+ private void doOnSucces(EnvProperties envProperties) {
+ logger.info("Fetching PRH configuration from ConfigBindingService/Consul");
+ Flux.just(httpClientExecutorService.callConsulForConfigBindingServiceEndpoint(envProperties))
+ .flatMap(configBindingServiceUri -> httpClientExecutorService.callConfigBindingServiceForPrhConfiguration(envProperties,
+ configBindingServiceUri)).subscribe();
+ }
+}
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
new file mode 100644
index 00000000..d1905108
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/EnvironmentProcessor.java
@@ -0,0 +1,85 @@
+/*
+ * ============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 java.util.Optional;
+import java.util.Properties;
+import org.onap.dcaegen2.services.prh.exceptions.EnvironmentLoaderException;
+import org.onap.dcaegen2.services.prh.model.EnvProperties;
+import org.onap.dcaegen2.services.prh.model.ImmutableEnvProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import reactor.core.publisher.Flux;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/10/18
+ */
+class EnvironmentProcessor {
+
+ private static Logger logger = LoggerFactory.getLogger(EnvironmentProcessor.class);
+
+ private EnvironmentProcessor() {
+ }
+
+ static Flux<EnvProperties> evaluate(Properties systemEnvironment) {
+ logger.info("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 Flux.error(e);
+ }
+ logger.info("Evaluated environment system variables {}", envProperties);
+ return Flux.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");
+ logger.warn("$CONSUL_PORT variable will be set to default port {}", 8500);
+ return 8500;
+ }
+}
+
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java
index f792c0ae..1bce1c07 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/SchedulerConfig.java
@@ -21,17 +21,23 @@
package org.onap.dcaegen2.services.prh.configuration;
import io.swagger.annotations.ApiOperation;
+import java.time.Duration;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
+import org.springframework.scheduling.support.PeriodicTrigger;
import reactor.core.publisher.Mono;
/**
@@ -39,17 +45,19 @@ import reactor.core.publisher.Mono;
*/
@Configuration
@EnableScheduling
-public class SchedulerConfig extends PrhAppConfig {
+public class SchedulerConfig extends CloudConfiguration {
- private static final int SCHEDULING_DELAY = 2000;
- private static volatile List<ScheduledFuture> scheduledFutureList = new ArrayList<>();
+ private static final int SCHEDULING_DELAY_FOR_PRH_TASKS = 2000;
+ private static final int SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY = 1;
+ private static volatile List<ScheduledFuture> scheduledPrgTaskFutureList = new ArrayList<>();
- private final TaskScheduler taskScheduler;
+ private final ConcurrentTaskScheduler taskScheduler;
private final ScheduledTasks scheduledTask;
@Autowired
- public SchedulerConfig(TaskScheduler taskScheduler, ScheduledTasks scheduledTask) {
- this.taskScheduler = taskScheduler;
+ public SchedulerConfig(@Qualifier("concurrentTaskScheduler") ConcurrentTaskScheduler concurrentTaskScheduler,
+ ScheduledTasks scheduledTask) {
+ this.taskScheduler = concurrentTaskScheduler;
this.scheduledTask = scheduledTask;
}
@@ -60,8 +68,8 @@ public class SchedulerConfig extends PrhAppConfig {
*/
@ApiOperation(value = "Get response on stopping task execution")
public synchronized Mono<ResponseEntity<String>> getResponseFromCancellationOfTasks() {
- scheduledFutureList.forEach(x -> x.cancel(false));
- scheduledFutureList.clear();
+ scheduledPrgTaskFutureList.forEach(x -> x.cancel(false));
+ scheduledPrgTaskFutureList.clear();
return Mono.defer(() ->
Mono.just(new ResponseEntity<>("PRH Service has already been stopped!", HttpStatus.CREATED))
);
@@ -72,16 +80,20 @@ public class SchedulerConfig extends PrhAppConfig {
*
* @return status of operation execution: true - started, false - not started
*/
+
@PostConstruct
@ApiOperation(value = "Start task if possible")
public synchronized boolean tryToStartTask() {
- if (scheduledFutureList.isEmpty()) {
- scheduledFutureList.add(taskScheduler
- .scheduleWithFixedDelay(scheduledTask::scheduleMainPrhEventTask, SCHEDULING_DELAY));
+ if (scheduledPrgTaskFutureList.isEmpty()) {
+ scheduledPrgTaskFutureList.add(cloudTaskScheduler
+ .scheduleAtFixedRate(super::runTask, Instant.now(),
+ Duration.ofMinutes(SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY)));
+ scheduledPrgTaskFutureList.add(taskScheduler
+ .scheduleWithFixedDelay(scheduledTask::scheduleMainPrhEventTask, SCHEDULING_DELAY_FOR_PRH_TASKS));
return true;
} else {
return false;
}
-
}
+
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java
new file mode 100644
index 00000000..5fef80d8
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/exceptions/EnvironmentLoaderException.java
@@ -0,0 +1,31 @@
+/*
+ * ============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.exceptions;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/10/18
+ */
+public class EnvironmentLoaderException extends Exception {
+
+ public EnvironmentLoaderException(String message) {
+ super(message);
+ }
+}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/EnvProperties.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/EnvProperties.java
new file mode 100644
index 00000000..c3895504
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/EnvProperties.java
@@ -0,0 +1,43 @@
+/*
+ * ============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.model;
+
+import org.immutables.value.Value;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/10/18
+ */
+@Value.Immutable(prehash = true)
+public interface EnvProperties {
+
+ @Value.Parameter
+ String consulHost();
+
+ @Value.Parameter
+ Integer consulPort();
+
+ @Value.Parameter
+ String cbsName();
+
+ @Value.Parameter
+ String appName();
+
+}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpClientExecutorService.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpClientExecutorService.java
new file mode 100644
index 00000000..01081f4d
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/HttpClientExecutorService.java
@@ -0,0 +1,47 @@
+/*
+ * ============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.service;
+
+import org.onap.dcaegen2.services.prh.model.EnvProperties;
+import org.reactivestreams.Publisher;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/10/18
+ */
+
+@Service
+public class HttpClientExecutorService {
+
+ public String callConsulForConfigBindingServiceEndpoint(EnvProperties envProperties) {
+ return null;
+ }
+
+ public Publisher<String> callConfigBindingServiceForPrhConfiguration(EnvProperties envProperties,
+ String configBindingServiceUri) {
+
+ return null;
+ }
+
+ private static class HttpGetClient {
+
+ }
+}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
index eed65c64..baccd3f3 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AaiProducerTaskImpl.java
@@ -21,7 +21,6 @@
package org.onap.dcaegen2.services.prh.tasks;
import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
-import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.exceptions.AaiNotFoundException;
import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
@@ -32,6 +31,7 @@ import org.onap.dcaegen2.services.prh.service.producer.AaiProducerReactiveHttpCl
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;
@@ -44,12 +44,12 @@ public class AaiProducerTaskImpl extends
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private final Config prhAppConfig;
+ private final Config config;
private AaiProducerReactiveHttpClient aaiProducerReactiveHttpClient;
@Autowired
- public AaiProducerTaskImpl(AppConfig prhAppConfig) {
- this.prhAppConfig = prhAppConfig;
+ public AaiProducerTaskImpl(@Qualifier("cloudConfiguration") Config config) {
+ this.config = config;
}
@Override
@@ -73,7 +73,7 @@ public class AaiProducerTaskImpl extends
@Override
protected AaiClientConfiguration resolveConfiguration() {
- return prhAppConfig.getAaiClientConfiguration();
+ return config.getAaiClientConfiguration();
}
@Override
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
index 812c04e1..180ad456 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
@@ -29,6 +29,7 @@ import org.onap.dcaegen2.services.prh.service.consumer.DMaaPConsumerReactiveHttp
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;
@@ -39,18 +40,18 @@ import reactor.core.publisher.Mono;
public class DmaapConsumerTaskImpl extends DmaapConsumerTask {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private final Config prhAppConfig;
+ private final Config config;
private DmaapConsumerJsonParser dmaapConsumerJsonParser;
private DMaaPConsumerReactiveHttpClient dmaaPConsumerReactiveHttpClient;
@Autowired
- public DmaapConsumerTaskImpl(AppConfig prhAppConfig) {
- this.prhAppConfig = prhAppConfig;
+ public DmaapConsumerTaskImpl(@Qualifier("cloudConfiguration") Config config) {
+ this.config = config;
this.dmaapConsumerJsonParser = new DmaapConsumerJsonParser();
}
DmaapConsumerTaskImpl(AppConfig prhAppConfig, DmaapConsumerJsonParser dmaapConsumerJsonParser) {
- this.prhAppConfig = prhAppConfig;
+ this.config = prhAppConfig;
this.dmaapConsumerJsonParser = dmaapConsumerJsonParser;
}
@@ -69,12 +70,12 @@ public class DmaapConsumerTaskImpl extends DmaapConsumerTask {
@Override
void initConfigs() {
- prhAppConfig.initFileStreamReader();
+ config.initFileStreamReader();
}
@Override
protected DmaapConsumerConfiguration resolveConfiguration() {
- return prhAppConfig.getDmaapConsumerConfiguration();
+ return config.getDmaapConsumerConfiguration();
}
@Override
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
index 1a641fd4..8188267e 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
@@ -21,7 +21,6 @@
package org.onap.dcaegen2.services.prh.tasks;
import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
@@ -29,6 +28,7 @@ import org.onap.dcaegen2.services.prh.service.producer.DMaaPProducerReactiveHttp
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;
@@ -39,12 +39,12 @@ import reactor.core.publisher.Mono;
public class DmaapPublisherTaskImpl extends DmaapPublisherTask {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private final Config prhAppConfig;
+ private final Config config;
private DMaaPProducerReactiveHttpClient dmaapProducerReactiveHttpClient;
@Autowired
- public DmaapPublisherTaskImpl(AppConfig prhAppConfig) {
- this.prhAppConfig = prhAppConfig;
+ public DmaapPublisherTaskImpl(@Qualifier("cloudConfiguration") Config config) {
+ this.config = config;
}
@Override
@@ -66,7 +66,7 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask {
@Override
protected DmaapPublisherConfiguration resolveConfiguration() {
- return prhAppConfig.getDmaapPublisherConfiguration();
+ return config.getDmaapPublisherConfiguration();
}
@Override