From 4026d98bc9802e41146ff6ef727d349c7ac1e89e Mon Sep 17 00:00:00 2001 From: Jakub Zieba Date: Tue, 4 Sep 2018 07:23:41 +0200 Subject: Add protocols to hosts Add default protocols for Consul hosts Add controller for healt check Fix for merging properties from file and Consul Change-Id: Ifa8c7cdfa333d8ffee175b5eb4446f0c3a986f27 Issue-ID: DCAEGEN2-747 Signed-off-by: Jakub Zieba --- src/main/java/org/onap/dcae/controller/ConfigSource.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java/org/onap/dcae/controller/ConfigSource.java') diff --git a/src/main/java/org/onap/dcae/controller/ConfigSource.java b/src/main/java/org/onap/dcae/controller/ConfigSource.java index 7e6a9fc8..c20a22a2 100644 --- a/src/main/java/org/onap/dcae/controller/ConfigSource.java +++ b/src/main/java/org/onap/dcae/controller/ConfigSource.java @@ -43,7 +43,7 @@ final class ConfigSource { .peek(strBody -> log.info(f("Received following CBS configuration from Consul '%s'", strBody))) .flatMap(strBody -> toJsonArray(strBody)) .flatMap(json -> withdrawCatalog(json)) - .flatMap(json -> constructFullCBSUrl(json)) + .flatMap(json -> constructFullCBSUrl(envProps, json)) .flatMap(cbsUrl -> callCBSForAppConfig(envProps, cbsUrl)) .flatMap(strBody -> toJson(strBody)) .peek(jsonNode -> log.info(f("Received app configuration: '%s'", jsonNode))) @@ -51,12 +51,14 @@ final class ConfigSource { } private static Try callConsulForCBSConfiguration(EnvProps envProps) { - return executeGet(envProps.consulHost + ":" + envProps.consulPort + "/v1/catalog/service/" + envProps.cbsName) + return executeGet(envProps.consulProtocol + "://" + envProps.consulHost + ":" + + envProps.consulPort + "/v1/catalog/service/" + envProps.cbsName) .mapFailure(enhanceError("Unable to retrieve CBS configuration from Consul")); } - private static Try constructFullCBSUrl(JSONObject json) { - return Try(() -> json.get("ServiceAddress").toString() + ":" + json.get("ServicePort").toString()) + private static Try constructFullCBSUrl(EnvProps envProps, JSONObject json) { + return Try(() -> envProps.cbsProtocol + "://" + json.get("ServiceAddress").toString() + ":" + + json.get("ServicePort").toString()) .mapFailure(enhanceError("ServiceAddress / ServicePort missing from CBS conf: '%s'", json)); } -- cgit 1.2.3-korg