Skip to content

Commit

Permalink
修改注册时的HostName
Browse files Browse the repository at this point in the history
  • Loading branch information
luanwenfei-venus committed Oct 8, 2023
1 parent f51e14f commit d0d1ffd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
21 changes: 21 additions & 0 deletions report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,27 @@
<artifactId>spring-cloud-registry-service</artifactId>
<version>${project.version}</version>
</dependency>
<!-- tag-transmission -->
<dependency>
<groupId>com.huaweicloud.sermant</groupId>
<artifactId>tag-transmission-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant</groupId>
<artifactId>tag-transmission-plugin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant</groupId>
<artifactId>tag-transmission-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant</groupId>
<artifactId>tag-transmission-rocketmq5.x-plugin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant</groupId>
<artifactId>sermant-backend</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,11 @@ private List<String> 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);
Expand Down

0 comments on commit d0d1ffd

Please sign in to comment.