X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=holmes-actions%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Fconfig%2FMicroServiceConfig.java;h=d86f56ce55c32acd344710f8a73fa3240bbc1bb2;hb=c8e4878d4f519e63a81bd30b30fcba0a0b398eb5;hp=bb78288be6d208a365fff8a39174406d1d35b8b9;hpb=9d2cccba20f32fe54e4ccf1f433f68b5cee95bd5;p=holmes%2Fcommon.git 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 bb78288..d86f56c 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 @@ -22,7 +22,6 @@ import lombok.extern.slf4j.Slf4j; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.glassfish.jersey.client.ClientConfig; -import org.onap.holmes.common.api.stat.Alarm; import org.onap.holmes.common.constant.AlarmConst; @Slf4j @@ -50,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")) { @@ -58,6 +58,7 @@ public class MicroServiceConfig { } catch (Exception e) { log.warn(e.getMessage(), e); } + log.info("The CBS address is " + ret); return ret; } @@ -72,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); } @@ -93,9 +95,18 @@ 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 + "."); + if (info != null){ - msbServerInfo = split(info); + JSONObject infoObj = JSONObject.fromObject(info); + String msbInfoTmp = infoObj.has("msb.hostname") ? infoObj.getString("msb.hostname") : null; + if (msbInfoTmp != null) { + msbServerInfo = split(msbInfoTmp); + } else { + msbServerInfo = split(getEnv(MSB_ADDR)); + } } else { msbServerInfo = split(getEnv(MSB_ADDR)); } @@ -106,6 +117,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 {