summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src
diff options
context:
space:
mode:
authorPiotr Wielebski <piotr.wielebski@nokia.com>2019-06-03 10:02:31 +0000
committerGerrit Code Review <gerrit@onap.org>2019-06-03 10:02:31 +0000
commitaa0e23d09507e7f675a747dd75120ed94e8c111d (patch)
tree80bdcbe07b2fb559d9d37d22fcd9cf59a3181e85 /prh-app-server/src
parenta7eed5cf5cefe05eeb2f5610d117b12d36b53512 (diff)
parentae956fcb64d6d36ccc2e892984fd7d2c194e3b87 (diff)
Merge "Adjust PRH with SDK"
Diffstat (limited to 'prh-app-server/src')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java12
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigFileReader.java25
2 files changed, 19 insertions, 18 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java
index 3f018b53..e262da55 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java
@@ -24,7 +24,7 @@ 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.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.model.CbsClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.DmaapClientFactory;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterPublisher;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.api.MessageRouterSubscriber;
@@ -58,23 +58,23 @@ public class CbsConfiguration implements Config {
}
public void runTask() {
- Flux.defer(this::resolveEnvProperties)
+ Flux.defer(this::resolveCbsClientConfiguration)
.subscribeOn(Schedulers.parallel())
.subscribe(this::parsingConfigSuccess, this::parsingConfigError);
}
- private Mono<EnvProperties> resolveEnvProperties() {
+ private Mono<CbsClientConfiguration> resolveCbsClientConfiguration() {
try {
- return Mono.just(EnvProperties.fromEnvironment());
+ return Mono.just(CbsClientConfiguration.fromEnvironment());
} catch(Exception e){
parsingConfigError(e);
return consulConfigFileReader.evaluate();
}
}
- private void parsingConfigSuccess(EnvProperties envProperties) {
+ private void parsingConfigSuccess(CbsClientConfiguration cbsClientConfiguration) {
LOGGER.debug("Fetching PRH configuration from Consul");
- CbsClientFactory.createCbsClient(envProperties)
+ CbsClientFactory.createCbsClient(cbsClientConfiguration)
.flatMap(cbsClient -> cbsClient.get(CbsRequests.getAll(RequestDiagnosticContext.create())))
.subscribe(this::parseCBSConfig, this::cbsConfigError);
}
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
index f11d9ff6..401db881 100644
--- 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
@@ -28,8 +28,9 @@ 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.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsClientConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableCbsClientConfiguration;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableCbsClientConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -42,21 +43,21 @@ public class ConsulConfigFileReader {
private static final Logger LOGGER = LoggerFactory.getLogger(ConsulConfigFileReader.class);
private static final int DEFAULT_CONSUL_PORT = 8500;
- private ImmutableEnvProperties jsonEnvProperties;
+ private ImmutableCbsClientConfiguration jsonCbsClientConfiguration;
@Value("classpath:consul_config.json")
private Resource consulConfig;
- public Mono<EnvProperties> evaluate() {
+ public Mono<CbsClientConfiguration> evaluate() {
initFileStreamReader();
- EnvProperties envProperties = ImmutableEnvProperties.builder()
- .consulHost(jsonEnvProperties.consulHost())
- .consulPort(Optional.ofNullable(jsonEnvProperties.consulPort()).orElse(DEFAULT_CONSUL_PORT))
- .cbsName(jsonEnvProperties.cbsName())
- .appName(jsonEnvProperties.appName())
+ CbsClientConfiguration cbsClientConfiguration = ImmutableCbsClientConfiguration.builder()
+ .consulHost(jsonCbsClientConfiguration.consulHost())
+ .consulPort(Optional.ofNullable(jsonCbsClientConfiguration.consulPort()).orElse(DEFAULT_CONSUL_PORT))
+ .cbsName(jsonCbsClientConfiguration.cbsName())
+ .appName(jsonCbsClientConfiguration.appName())
.build();
- LOGGER.info("Evaluated variables: {}", envProperties);
- return Mono.just(envProperties);
+ LOGGER.info("Evaluated variables: {}", cbsClientConfiguration);
+ return Mono.just(cbsClientConfiguration);
}
private void initFileStreamReader() {
@@ -65,7 +66,7 @@ public class ConsulConfigFileReader {
try (InputStream inputStream = consulConfig.getInputStream()) {
JsonElement rootElement = getJsonElement(inputStream);
if (rootElement.isJsonObject()) {
- jsonEnvProperties = gson.fromJson(rootElement, ImmutableEnvProperties.class);
+ jsonCbsClientConfiguration = gson.fromJson(rootElement, ImmutableCbsClientConfiguration.class);
}
} catch (IOException e) {
LOGGER.warn("Failed to load/parse file", e);