From d0d1ffdcf8e85997c886aea2abc2c4cc54ab5662 Mon Sep 17 00:00:00 2001 From: luanwenfei Date: Sun, 8 Oct 2023 17:29:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E5=86=8C=E6=97=B6?= =?UTF-8?q?=E7=9A=84HostName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- report/pom.xml | 21 +++++++++++++++++++ .../registry/service/RegistryServiceImpl.java | 3 ++- .../registry/service/client/ScClient.java | 6 +++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/report/pom.xml b/report/pom.xml index 720803022f..81bcd0f6f8 100644 --- a/report/pom.xml +++ b/report/pom.xml @@ -126,6 +126,27 @@ spring-cloud-registry-service ${project.version} + + + com.huaweicloud.sermant + tag-transmission-common + ${project.version} + + + com.huaweicloud.sermant + tag-transmission-plugin + ${project.version} + + + com.huaweicloud.sermant + tag-transmission-service + ${project.version} + + + com.huaweicloud.sermant + tag-transmission-rocketmq5.x-plugin + ${project.version} + com.huaweicloud.sermant sermant-backend diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/service/RegistryServiceImpl.java b/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/service/RegistryServiceImpl.java index eff485f22f..32e8e91b8f 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/service/RegistryServiceImpl.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/service/RegistryServiceImpl.java @@ -394,7 +394,8 @@ private void createMicroserviceInstance() { private String getHost() { try { - return InetAddress.getLocalHost().getHostName(); + String hostName = InetAddress.getLocalHost().getHostName(); + return hostName.length() > 64 ? hostName.substring(0, 64) : hostName; } catch (UnknownHostException e) { LOGGER.warning("Cannot get the host."); return ""; diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-service/src/main/java/com/huawei/registry/service/client/ScClient.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-service/src/main/java/com/huawei/registry/service/client/ScClient.java index 7c354867de..59755a9bec 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-service/src/main/java/com/huawei/registry/service/client/ScClient.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-service/src/main/java/com/huawei/registry/service/client/ScClient.java @@ -418,7 +418,11 @@ private List buildEndpoints() { private void buildMicroServiceInstance() { microserviceInstance = new MicroserviceInstance(); microserviceInstance.setStatus(MicroserviceInstanceStatus.UP); - microserviceInstance.setHostName(RegisterContext.INSTANCE.getClientInfo().getHost()); + String hostName = RegisterContext.INSTANCE.getClientInfo().getHost(); + if (hostName != null) { + hostName = hostName.length() > 64 ? hostName.substring(0, 64) : hostName; + } + microserviceInstance.setHostName(hostName); microserviceInstance.setEndpoints(buildEndpoints()); HealthCheck healthCheck = new HealthCheck(); healthCheck.setMode(HealthCheckMode.push);