diff options
3 files changed, 17 insertions, 13 deletions
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/config/MicroServiceConfig.java b/holmes-actions/src/main/java/org/openo/holmes/common/config/MicroServiceConfig.java index ba55562..9c6ab3c 100644 --- a/holmes-actions/src/main/java/org/openo/holmes/common/config/MicroServiceConfig.java +++ b/holmes-actions/src/main/java/org/openo/holmes/common/config/MicroServiceConfig.java @@ -15,22 +15,24 @@ */
package org.openo.holmes.common.config;
+import org.openo.holmes.common.constant.AlarmConst;
+
public class MicroServiceConfig {
- private static String getProperty(String name) {
- String value = System.getenv(name);
- if (value == null) {
- value = System.getProperty(name);
+ private static String getProperty(String name) {
+ String value = System.getenv(name);
+ if (value == null) {
+ value = System.getProperty(name);
+ }
+ return value;
}
- return value;
- }
- public static String getMsbServerAddr() {
- return getProperty("MSB_ADDR");
- }
+ public static String getMsbServerAddr() {
+ return getProperty("MSB_ADDR") + ":" + AlarmConst.MICRO_SERVICE_PORT;
+ }
- public static String getServiceIp() {
- return getProperty("SERVICE_IP");
- }
+ public static String getServiceIp() {
+ return getProperty("SERVICE_IP");
+ }
}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/constant/AlarmConst.java b/holmes-actions/src/main/java/org/openo/holmes/common/constant/AlarmConst.java index 3894bf3..40e15eb 100644 --- a/holmes-actions/src/main/java/org/openo/holmes/common/constant/AlarmConst.java +++ b/holmes-actions/src/main/java/org/openo/holmes/common/constant/AlarmConst.java @@ -34,4 +34,6 @@ public interface AlarmConst { String ADMIN = "admin";
int MICRO_SERVICE_STATUS_SUCCESS = 201;
+
+ int MICRO_SERVICE_PORT = 8086;
}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java index 826fbd0..5e806e4 100644 --- a/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java +++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/MSBRegisterUtil.java @@ -41,7 +41,7 @@ public class MSBRegisterUtil { ObjectMapper mapper = new ObjectMapper();
String content = mapper.writeValueAsString(entity);
HttpPost httpPost = new HttpPost("http://" + MicroServiceConfig.getMsbServerAddr()
- + ":8086/api/microservices/v1/services?createOrUpdate=false");
+ + "/api/microservices/v1/services?createOrUpdate=false");
if (StringUtils.isNotEmpty(content)) {
httpPost.setEntity(new ByteArrayEntity(content.getBytes()));
}
|