From 3dfe506a8ea1bec7096da63541e426958d04a1a0 Mon Sep 17 00:00:00 2001 From: Guangrong Fu Date: Mon, 30 Oct 2017 15:01:53 +0800 Subject: Update the logic for MSB addr retrieving Change-Id: Id4258d763489f622f68c8152bb89e093993d1982 Issue-ID: HOLMES-81 Signed-off-by: Guangrong Fu --- .../java/org/onap/holmes/common/config/MicroServiceConfig.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'holmes-actions/src/main') diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java b/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java index 01a5f2e..212bc66 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java @@ -49,6 +49,7 @@ public class MicroServiceConfig { public static String getConfigBindingServiceAddrInfo() { String ret = null; String queryString = getConsulAddrInfo() + CONFIG_BINDING_SERVICE; + log.info("Query the CBS address using the URL: " + queryString); try { JSONObject addrJson = (JSONObject) JSONArray.fromObject(execQuery(queryString)).get(0); if (addrJson.has("ServiceAddress") && addrJson.has("ServicePort")) { @@ -57,6 +58,7 @@ public class MicroServiceConfig { } catch (Exception e) { log.warn(e.getMessage(), e); } + log.info("The CBS address is " + ret); return ret; } @@ -71,6 +73,7 @@ public class MicroServiceConfig { String url = getConfigBindingServiceAddrInfo() + "/service_component/" +serviceName; try { JSONObject jsonObject = JSONObject.fromObject(execQuery(url)); + log.info("The origin configurations (" + url + ") returned by DCAE is: " + jsonObject.toString()); if (jsonObject.has(serviceName)) { ret = (String) jsonObject.getJSONArray(serviceName).get(0); } @@ -92,7 +95,11 @@ public class MicroServiceConfig { public static String[] getMsbAddrInfo() { String[] msbServerInfo = null; - String info = getServiceAddrInfoFromCBS(MSB_ADDR); + //String info = getServiceAddrInfoFromCBS(MSB_ADDR); + String info = getServiceAddrInfoFromCBS(getEnv(HOSTNAME)); + log.info("Got the service information of \"" + getEnv(HOSTNAME) + "\" from CBS. The response is " + info + "."); + JSONObject infoObj = JSONObject.fromObject(info); + info = infoObj.has("msb.hostname") ? infoObj.getString("msb.hostname") : null; if (info != null){ msbServerInfo = split(info); } else { @@ -105,6 +112,7 @@ public class MicroServiceConfig { public static String[] getServiceAddrInfo() { String[] serviceAddrInfo = null; String info = getServiceAddrInfoFromCBS(getEnv(HOSTNAME)); + log.info("Got the service information of \"" + getEnv(HOSTNAME) + "\" from CBS. The response is " + info + "."); if (info != null){ serviceAddrInfo = split(info); } else { -- cgit 1.2.3-korg