Merge pull request #2938 from alibaba/hotfix_naming_compatibility

[#2933] adjust where version information is inserted
This commit is contained in:
liaochuntao 2020-06-02 14:10:27 +08:00 committed by GitHub
commit 3c23ed09b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -17,7 +17,6 @@
package com.alibaba.nacos.core.cluster;
import com.alibaba.nacos.common.utils.ExceptionUtil;
import com.alibaba.nacos.common.utils.VersionUtils;
import com.alibaba.nacos.core.utils.ApplicationUtils;
import com.alibaba.nacos.core.utils.Loggers;
import java.util.concurrent.ThreadLocalRandom;
@ -75,7 +74,6 @@ public class MemberUtils {
Map<String, Object> extendInfo = new HashMap<>(4);
// The Raft Port information needs to be set by default
extendInfo.put(MemberMetaDataConstants.RAFT_PORT, String.valueOf(calculateRaftPort(target)));
extendInfo.put(MemberMetaDataConstants.VERSION, VersionUtils.VERSION);
target.setExtendInfo(extendInfo);
return target;
}

View File

@ -139,6 +139,7 @@ public class ServerMemberManager
this.port = ApplicationUtils.getProperty("server.port", Integer.class, 8848);
this.localAddress = InetUtils.getSelfIp() + ":" + port;
this.self = MemberUtils.singleParse(this.localAddress);
this.self.setExtendVal(MemberMetaDataConstants.VERSION, VersionUtils.VERSION);
serverList.put(self.getAddress(), self);
// register NodeChangeEvent publisher to NotifyManager

View File

@ -28,6 +28,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@ -104,7 +105,7 @@ public class DistroMapper implements MemberChangeListener {
int index = distroHash(serviceName) % servers.size();
return servers.get(index);
} catch (Throwable e) {
Loggers.SRV_LOG.warn("distro mapper failed, return localhost: " + ApplicationUtils.getLocalAddress(), e);
Loggers.SRV_LOG.warn("[NACOS-DISTRO] distro mapper failed, return localhost: " + ApplicationUtils.getLocalAddress(), e);
return ApplicationUtils.getLocalAddress();
}
}
@ -119,8 +120,9 @@ public class DistroMapper implements MemberChangeListener {
// node list is in the same order
List<String> list = MemberUtils.simpleMembers(event.getMembers());
Collections.sort(list);
Collection<String> old = healthyList;
healthyList = Collections.unmodifiableList(list);
System.out.println(healthyList);
Loggers.SRV_LOG.info("[NACOS-DISTRO] healthy server list changed, old: {}, new: {}", old, healthyList);
}
@Override