diff options
author | Guangrong Fu <fu.guangrong@zte.com.cn> | 2021-12-02 19:42:55 +0800 |
---|---|---|
committer | Guangrong Fu <fu.guangrong@zte.com.cn> | 2021-12-02 19:43:44 +0800 |
commit | c073e7c959231d9873d465e47b1eae1ff5cfc265 (patch) | |
tree | 84de86fd8dabd7c3383175314f56449c7ce52999 /holmes-actions/src/main | |
parent | 8e140d4ae66e73547836103aa79d8b55ef937847 (diff) |
Fixed some bugs
Issue-ID: HOLMES-488
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Change-Id: I7f113a7f4d753c3c3e8d1f780e00c5fce9aab3de
Diffstat (limited to 'holmes-actions/src/main')
4 files changed, 12 insertions, 17 deletions
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 97c7141..191d897 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 @@ -24,7 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory;
import static org.onap.holmes.common.utils.CommonUtils.getEnv;
-import static org.onap.holmes.common.utils.CommonUtils.isIpAddress;
public class MicroServiceConfig {
@@ -97,22 +96,14 @@ public class MicroServiceConfig { }
public static String[] getMicroServiceIpAndPort() {
- String[] serviceAddrInfo = null;
- String info = getServiceAddrInfoFromDcaeConsulByHostName(getEnv(HOSTNAME));
- log.info("Got the service information of \"" + getEnv(HOSTNAME) + "\" from Consul. The response is " + info + ".");
-
- if (info != null && !info.isEmpty()) {
- if (!isIpAddress(info)) {
- info = getEnv(POD_IP);
- }
- serviceAddrInfo = split(info);
+ String info = getEnv(POD_IP);
+ if (info != null) {
+ return split(info);
} else {
- serviceAddrInfo = split(getEnv(HOSTNAME));
+ return split(getEnv(HOSTNAME));
}
- return serviceAddrInfo;
}
-
private static String[] split(String addr) {
String ip;
String port = "80";
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java index 4f8a0a5..2c963d8 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java @@ -20,6 +20,7 @@ import org.onap.holmes.common.dcae.entity.DcaeConfigurations; import org.onap.holmes.common.dcae.utils.DcaeConfigurationParser; import org.onap.holmes.common.exception.CorrelationException; +@Deprecated public class DcaeConfigurationQuery { public static DcaeConfigurations getDcaeConfigurations(String hostname) diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/FileUtils.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/FileUtils.java index cf5de1c..a512c83 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/FileUtils.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/FileUtils.java @@ -27,6 +27,7 @@ import java.io.IOException; public class FileUtils { final static private Logger LOGGER = LoggerFactory.getLogger(FileUtils.class); + final static private String LINE_SEPARATOR = System.getProperty ("line.separator"); static public String readTextFile(String path) { try { @@ -34,9 +35,9 @@ public class FileUtils { StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { - sb.append(line); + sb.append(line).append(LINE_SEPARATOR); } - return sb.toString(); + return sb.substring(0, sb.length() - 1); } catch (FileNotFoundException e) { LOGGER.warn("No file found: {}", path); } catch (IOException e) { diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java index 871ffad..cfb601a 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java @@ -197,12 +197,14 @@ public class JerseyClient { private boolean isSuccessful(Response response, String url) { Response.StatusType statusInfo = response.getStatusInfo(); if (statusInfo.getFamily() != Response.Status.Family.SUCCESSFUL) { - throw new HttpException(statusInfo.getStatusCode(), - String.format("Failed to get response from the server. " + + logger.error( + String.format("Failed to get response from the server <%d>. " + "\nURL: %s\nCause: %s\nResponse body: %s", + statusInfo.getStatusCode(), url, statusInfo.getReasonPhrase(), response.readEntity(String.class))); + return false; } return true; } |