From 31c419d91ab4f6b5644e1cb9c7a477038fbd3dea Mon Sep 17 00:00:00 2001 From: youbowu Date: Thu, 9 Mar 2017 19:20:43 +0800 Subject: Modify port Issue-ID: HOLMES-50 Change-Id: I872a0def568da1be5d98b042b932f13e02c5f3df Signed-off-by: youbowu --- .../holmes/common/config/MicroServiceConfig.java | 26 ++++++++++++---------- .../openo/holmes/common/constant/AlarmConst.java | 2 ++ .../openo/holmes/common/utils/MSBRegisterUtil.java | 2 +- 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())); } -- cgit 1.2.3-korg