nacos服务注册流程
创始人
2024-09-25 07:20:02
0

一、客户端自动注册实例流程

1.首先客户端需要引入服务发现包

  com.alibaba.cloud   spring-cloud-starter-alibaba-nacos-discovery   2.2.6.RELEASE

2.  NacosServiceRegistryAutoConfiguration 配置类

此类在spring-cloud-starter-alibaba-nacos-discovery客户包里面会自动在当前SPRINGBOOT容器注册

3.此配置类最核心的实体注册类为NacosAutoServiceRegistration,

查看此类的继承属性

发现此类继承于spring cloud common的AbstractAutoServiceRegistration抽象继承类,此类包含了与SPRING对接的一系列自动注册功能。并且实现了ApplicationListener接口,所以会监听SPRING WEB事件。

4.监听ServletWebServerInitializedEvent事件

5.AbstractAutoServiceRegistration自动更新服务端口

6.NacosAutoServiceRegistration更新端口,以及配置里面的分组,集群等信息。

7.跳到父类的注册方法

8.最终调用了NacosServiceRegistry.registry

9.接着触发了NacosNamingService.registerInstance

注意这里,如果是临时节点,还会触发客户端定时发送心跳。

这里已经跳到了nacos-client-1.4.2的包,相当于是具体注册中心客户端的实现。

10.接着跳到了NamingProxy.registerService,

11.最终发起HTTP调用请求,NamingProxy

public String reqApi(String api, Map params, Map body, List servers,             String method) throws NacosException {                  params.put(CommonParams.NAMESPACE_ID, getNamespaceId());                  if (CollectionUtils.isEmpty(servers) && StringUtils.isBlank(nacosDomain)) {             throw new NacosException(NacosException.INVALID_PARAM, "no server available");         }                  NacosException exception = new NacosException();                  if (StringUtils.isNotBlank(nacosDomain)) {             for (int i = 0; i < maxRetry; i++) {                 try {                     return callServer(api, params, body, nacosDomain, method);                 } catch (NacosException e) {                     exception = e;                     if (NAMING_LOGGER.isDebugEnabled()) {                         NAMING_LOGGER.debug("request {} failed.", nacosDomain, e);                     }                 }             }         } else {             Random random = new Random(System.currentTimeMillis());             int index = random.nextInt(servers.size());                          for (int i = 0; i < servers.size(); i++) {                 String server = servers.get(index);                 try {                     return callServer(api, params, body, server, method);                 } catch (NacosException e) {                     exception = e;                     if (NAMING_LOGGER.isDebugEnabled()) {                         NAMING_LOGGER.debug("request {} failed.", server, e);                     }                 }                 index = (index + 1) % servers.size();             }         }                  NAMING_LOGGER.error("request: {} failed, servers: {}, code: {}, msg: {}", api, servers, exception.getErrCode(),                 exception.getErrMsg());                  throw new NacosException(exception.getErrCode(),                 "failed to req API:" + api + " after all servers(" + servers + ") tried: " + exception.getMessage());              }     

如果是带域名,或者单机运行,则直接发起HTTP调用,如果是集群NACOS服务列表,则随机找到一台NACOS服务器发起请求。

12.客户端注册完成

二、服务端注册流程

1.下载1.4.2源码,本地启动

-Dnacos.standalone=true -Dnacos.home=e:\\nacos

启动类为com.alibaba.nacos.Nacos

2.服务端是SPRINGBOOT项目,找到控制器接口

3.首先进入InstanceController.register

4.进入ServiceManager.register,此类就是客户端服务实例的管理类,保存客户端实例的注册表。

@Component public class ServiceManager implements RecordListener {          /**      * Map(namespace, Map(group::serviceName, Service)). 真正的注册表      */     private final Map> serviceMap = new ConcurrentHashMap<>();          private final LinkedBlockingDeque toBeUpdatedServicesQueue = new LinkedBlockingDeque<>(1024 * 1024);          private final Synchronizer synchronizer = new ServiceStatusSynchronizer();          private final Lock lock = new ReentrantLock();          @Resource(name = "consistencyDelegate")     //一致性协调协议      private ConsistencyService consistencyService;          private final SwitchDomain switchDomain;          private final DistroMapper distroMapper;          private final ServerMemberManager memberManager;          private final PushService pushService;          private final RaftPeerSet raftPeerSet;

5.如果服务不存在,则会创建一个空的Service对象。

注意,此时的servicename已经带了分组了。

6.调试日志输出等级

因为服务端源码有多个线程协作,调试比较麻烦,建议看代码,然后加日志打印输出。

可以把naming的LOGBACK日志输出等级调成DEBUG

                             ${LOG_HOME}/naming-server.log         true                      ${LOG_HOME}/naming-server.log.%d{yyyy-MM-dd}.%i             2GB             15             7GB             true                               %date %level  [%C:%M:%L] %msg%n%n             UTF-8                            ${LOG_HOME}/naming-raft.log         true                      ${LOG_HOME}/naming-raft.log.%d{yyyy-MM-dd}.%i             20MB             15             128MB             true                               %date %level  [%C:%M:%L] %msg%n%n             UTF-8                            ${LOG_HOME}/naming-event.log         true                      ${LOG_HOME}/naming-event.log.%d{yyyy-MM-dd}.%i             20MB             15             128MB             true                               %date %level [%C:%M:%L] %msg%n%n             UTF-8                            ${LOG_HOME}/naming-push.log         true                      ${LOG_HOME}/naming-push.log.%d{yyyy-MM-dd}.%i             20MB             15             128MB             true                               %date %level  [%C:%M:%L] %msg%n%n             UTF-8                            ${LOG_HOME}/naming-rt.log         true                      ${LOG_HOME}/naming-rt.log.%d{yyyy-MM-dd}.%i             1GB             15             3GB             true                               %date %level  [%C:%M:%L] %msg%n%n             UTF-8                             ${LOG_HOME}/naming-performance.log         true                      ${LOG_HOME}/naming-performance.log.%d{yyyy-MM-dd}.%i             50MB             15             512MB             true                               %date %level  [%C:%M:%L] %msg%n%n             UTF-8                             ${LOG_HOME}/naming-router.log         true                      ${LOG_HOME}/naming-router.log.%d{yyyy-MM-dd}.%i             2GB             15             7GB             true                               %date|%msg%n             UTF-8                             ${LOG_HOME}/naming-cache.log         true                      ${LOG_HOME}/naming-cache.log.%d{yyyy-MM-dd}.%i             1GB             15             3GB             true                               %date|%msg%n             UTF-8                             ${LOG_HOME}/naming-device.log         true                      ${LOG_HOME}/naming-device.log.%d{yyyy-MM-dd}.%i             2GB             15             7GB             true                               %date|%msg%n             UTF-8                             ${LOG_HOME}/naming-tag.log         true                      ${LOG_HOME}/naming-tag.log.%d{yyyy-MM-dd}.%i             1GB             15             3GB             true                               %date %level %msg%n%n             UTF-8                             ${LOG_HOME}/naming-debug.log         true                      ${LOG_HOME}/naming-debug.log.%d{yyyy-MM-dd}.%i             20MB             15             128MB             true                               %date %level %msg%n%n             UTF-8                             ${LOG_HOME}/naming-distro.log         true                      ${LOG_HOME}/naming-distro.log.%d{yyyy-MM-dd}.%i             1GB             7             3GB             true                               %date %level  [%C:%M:%L] %msg%n%n             UTF-8                                          %date %level [%thread] [%C:%M:%L] %msg%n%n             UTF-8                                                                                                                                                                                                                                                                                                                                                                          

7.业务日志APPENDER类分析

有一个统一的日志输出类,将各种业务分别用不同的APPENDER对象输出

public class Loggers {      //客户端推送     public static final Logger PUSH = LoggerFactory.getLogger("com.alibaba.nacos.naming.push");      //心跳检测     public static final Logger CHECK_RT = LoggerFactory.getLogger("com.alibaba.nacos.naming.rt");      //服务相关业务     public static final Logger SRV_LOG = LoggerFactory.getLogger("com.alibaba.nacos.naming.main");      //通知事件,如新服务注册,变更,下线等。     public static final Logger EVT_LOG = LoggerFactory.getLogger("com.alibaba.nacos.naming.event");       //一致性RAFT系统 CP     public static final Logger RAFT = LoggerFactory.getLogger("com.alibaba.nacos.naming.raft");      //一致性协议 ,AP     public static final Logger DISTRO = LoggerFactory.getLogger("com.alibaba.nacos.naming.distro");       //性能分析     public static final Logger PERFORMANCE_LOG = LoggerFactory.getLogger("com.alibaba.nacos.naming.performance");

8.注册后的serviceMap结构如下:

单个Service的示例结构如下:

{     "name":"mall@@joyday",     "protectThreshold":0,     "groupName":"mall",     "metadata":{      },     "finalizeCount":2,     "owners":[      ],     "resetWeight":false,     "enabled":true,     "selector":{         "type":"none"     },     "namespaceId":"public",     "ipDeleteTimeout":30000,     "lastModifiedMillis":1722671874301,     "checksum":"f936119262bea62fbfbb16c10f955e96",     "clusterMap":{         "beijing":{             "serviceName":"mall@@joyday",             "name":"beijing",             "healthChecker":{                 "type":"TCP"             },             "defaultPort":80,             "defaultCheckPort":80,             "useIPPort4Check":true,             "metadata":{              },             "sitegroup":"",             "defCkport":80,             "empty":false,             "defIPPort":80         }     },     "empty":false }

9.进入ServiceMananger.addInstance,查看保存到一致性服务的dataStore中的KEY,为命名空间+分组+服务名,值为Instances,这个对象里面又包含了一个instance的LIST.

10.进入ServiceMananger.updateIpAddresses,可以更详细看到dataMap,这个就是把dataMap当作旧的注册表,把二级缓存Service中的ClusterMap作为新对象进行比较,从而把新的实例加进到datamap中。

11.进入到DistroConsistencyServiceImpl.onPut,查看单个dataTum

12.Service为其中一个listener,异步收到消息。

13.再将变化的Instances中的实例保存重新刷新到Service的clusterMap中,Service.

updateIPs

注意在这里,会给pushService发出通知,通知相关客户端此服务的实例发生变化。

14.我们再启动一个新的实例,查看clusterMap,dataStore的变化。看到端口变成了8066

15.第一次8064服务启动日志

2024-08-03 16:40:36,500 DEBUG [http-nio-8848-exec-5] [com.alibaba.nacos.naming.controllers.InstanceController:doSrvIpxt:691] no instance to serve for service: mall@@joyday  2024-08-03 16:40:37,151 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.ServiceManager:createServiceIfAbsent:471] creating empty service public:mall@@joyday  2024-08-03 16:40:37,158 DEBUG [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.Service:recalculateChecksum:549] service to json: {"invalidIPCount":0,"name":"mall@@joyday","ipCount":0,"owners":[],"protectThreshold":0.0,"clusters":[]}  2024-08-03 16:40:37,162 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.consistency.persistent.raft.RaftCore:listen:962] add listener: com.alibaba.nacos.naming.iplist.public##mall@@joyday  2024-08-03 16:40:37,251 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.ServiceManager:putServiceAndInit:902] [NEW-SERVICE] {"name":"mall@@joyday","protectThreshold":0.0,"groupName":"mall","metadata":{},"finalizeCount":0,"owners":[],"resetWeight":false,"enabled":true,"selector":{"type":"none"},"namespaceId":"public","ipDeleteTimeout":30000,"lastModifiedMillis":1722674437153,"checksum":"45e19250c6a2ded80ed14b5aca7a6ee4","clusterMap":{},"empty":true}  2024-08-03 16:40:37,251 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.ServiceManager:createServiceIfAbsent:491] createServiceIfAbsent end getClusterMap {}  2024-08-03 16:40:37,251 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.ServiceManager:addInstance:652]  addInstance key:com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday  2024-08-03 16:40:37,252 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.ServiceManager:updateIpAddresses:806]  updateIpAddresses before  currentIPs:[],instanceMap:{}  2024-08-03 16:40:37,257 WARN [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.ServiceManager:updateIpAddresses:815] cluster: beijing not found, ip: {"instanceId":"10.6.33.23#8064#beijing#mall@@joyday","ip":"10.6.33.23","port":8064,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722674437147,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}, will create new cluster with default configuration.  2024-08-03 16:40:37,259 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.ServiceManager:updateIpAddresses:839]  updateIpAddresses after  currentIPs:[],instanceMap:{10.6.33.23:8064:unknown:beijing=10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing}  2024-08-03 16:40:37,259 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.core.ServiceManager:addInstance:661]  addInstance after addIpAddresses new instanceList:[10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing]  2024-08-03 16:40:37,259 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:put:108]  distro put key:com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday,value:{"instanceList":[{"instanceId":"10.6.33.23#8064#beijing#mall@@joyday","ip":"10.6.33.23","port":8064,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722674437147,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}]}  2024-08-03 16:40:37,260 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:onPut:132] createServiceIfAbsent start dataStore {}  2024-08-03 16:40:37,260 INFO [http-nio-8848-exec-7] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:onPut:141] createServiceIfAbsent end dataStore {com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday=com.alibaba.nacos.naming.consistency.Datum@72f532aa}  2024-08-03 16:40:37,263 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:onChange:178] [NACOS-RAFT] datum service is changed, key: com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday, value: {"instanceList":[{"instanceId":"10.6.33.23#8064#beijing#mall@@joyday","ip":"10.6.33.23","port":8064,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722674437147,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}]}  2024-08-03 16:40:37,263 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:updateIPs:237] updateIPs before, instances: [10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing], ephemeral: true  2024-08-03 16:40:37,264 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Cluster:updateIps:277] mall@@joyday {SYNC} {IP-NEW} cluster: beijing, new ips size: 1, content: [10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing]  2024-08-03 16:40:37,266 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:updateIPs:290] [IP-UPDATED] namespace: public, service: mall@@joyday, ips: 10.6.33.23:8064_true,  2024-08-03 16:40:37,269 DEBUG [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:recalculateChecksum:549] service to json: {"invalidIPCount":0,"name":"mall@@joyday","ipCount":1,"owners":[],"protectThreshold":0.0,"clusters":[{"healthChecker":{},"defIPPort":80,"defCkport":80,"name":"beijing","useIPPort4Check":true,"sitegroup":""}]}  2024-08-03 16:40:37,269 DEBUG [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl$Notifier:handle:447] [NACOS-DISTRO] datum change notified, key: com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday, listener count: 1, action: CHANGE  2024-08-03 16:40:38,267 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:lambda$onApplicationEvent$1:127] mall@@joyday is changed, add it to push queue.  2024-08-03 16:40:38,272 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:lambda$onApplicationEvent$1:166] serviceName: mall@@joyday changed, schedule push for: 10.6.33.23:62522, agent: Nacos-Java-Client:v1.4.2, key: 10.6.33.23,62522,373503109817900  2024-08-03 16:40:38,272 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:udpPush:614] send udp packet: 10.6.33.23,62522,373503109817900  2024-08-03 16:40:38,278 INFO [com.alibaba.nacos.naming.push.receiver] [com.alibaba.nacos.naming.push.PushService$Receiver:run:687] received ack: {"type": "push-ack", "lastRefTime":"373503109817900", "data":""} from: 10.6.33.23:62522, cost: 6 ms, unacked: 0, total push: 1  

dataStore-dataTum

 key:com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday

{com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday

com.alibaba.nacos.naming.consistency.Datum@72f532aa}

{     "instanceList":[         {             "instanceId":"10.6.33.23#8064#beijing#mall@@joyday",             "ip":"10.6.33.23",             "port":8064,             "weight":1,             "healthy":true,             "enabled":true,             "ephemeral":true,             "clusterName":"beijing",             "serviceName":"mall@@joyday",             "metadata":{                 "preserved.register.source":"SPRING_CLOUD"             },             "lastBeat":1722674437147,             "marked":false,             "app":"unknown",             "instanceHeartBeatInterval":5000,             "instanceHeartBeatTimeOut":15000,             "ipDeleteTimeout":30000         }     ] }

servicemap结构

{public={mall@@joyday=Service{name='mall@@joyday', protectThreshold=0.0, appName='null', groupName='mall', metadata={}}}}

16.第二次8066服务启动日志

2024-08-03 16:53:45,870 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.core.ServiceManager:createServiceIfAbsent:492] createServiceIfAbsent end getClusterMap {beijing=com.alibaba.nacos.naming.core.Cluster@f27590dd}  2024-08-03 16:53:45,870 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.core.ServiceManager:addInstance:653]  addInstance key:com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday  2024-08-03 16:53:45,870 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.core.ServiceManager:addInstance:656]  addInstance ,serviceMap:{public={mall@@joyday=Service{name='mall@@joyday', protectThreshold=0.0, appName='null', groupName='mall', metadata={}}}}  2024-08-03 16:53:45,871 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.core.ServiceManager:updateIpAddresses:809]  updateIpAddresses before  currentIPs:[10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing],instanceMap:{10.6.33.23:8064:unknown:beijing=10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing}  2024-08-03 16:53:45,871 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.core.ServiceManager:updateIpAddresses:842]  updateIpAddresses after  currentIPs:[10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing],instanceMap:{10.6.33.23:8064:unknown:beijing=10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing=10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing}  2024-08-03 16:53:45,872 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.core.ServiceManager:addInstance:664]  addInstance after addIpAddresses new instanceList:[10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing]  2024-08-03 16:53:45,872 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:put:108]  distro put key:com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday,value:{"instanceList":[{"instanceId":"10.6.33.23#8064#beijing#mall@@joyday","ip":"10.6.33.23","port":8064,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"dubbo.metadata-service.urls":"[ \"dubbo://10.6.33.23:20880/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=joyday&bind.ip=10.6.33.23&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=joyday&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=38352&qos.enable=false&release=2.7.8&revision=2.2.6.RELEASE&side=provider×tamp=1722675134397&version=1.0.0\" ]","dubbo.metadata.revision":"0","preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722675221548,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000},{"instanceId":"10.6.33.23#8066#beijing#mall@@joyday","ip":"10.6.33.23","port":8066,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722675225870,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}]}  2024-08-03 16:53:45,872 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:onPut:132] createServiceIfAbsent start dataStore {com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday=com.alibaba.nacos.naming.consistency.Datum@41cab4c3}  2024-08-03 16:53:45,872 INFO [http-nio-8848-exec-6] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:onPut:141] createServiceIfAbsent end dataStore {com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday=com.alibaba.nacos.naming.consistency.Datum@36aea586}  2024-08-03 16:53:45,872 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:onChange:178] [NACOS-RAFT] datum service is changed, key: com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday, value: {"instanceList":[{"instanceId":"10.6.33.23#8064#beijing#mall@@joyday","ip":"10.6.33.23","port":8064,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"dubbo.metadata-service.urls":"[ \"dubbo://10.6.33.23:20880/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=joyday&bind.ip=10.6.33.23&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=joyday&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=38352&qos.enable=false&release=2.7.8&revision=2.2.6.RELEASE&side=provider×tamp=1722675134397&version=1.0.0\" ]","dubbo.metadata.revision":"0","preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722675221548,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000},{"instanceId":"10.6.33.23#8066#beijing#mall@@joyday","ip":"10.6.33.23","port":8066,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722675225870,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}]}  2024-08-03 16:53:45,873 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:updateIPs:237] updateIPs before, instances: [10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing], ephemeral: true  2024-08-03 16:53:45,873 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Cluster:updateIps:277] mall@@joyday {SYNC} {IP-NEW} cluster: beijing, new ips size: 1, content: [10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing]  2024-08-03 16:53:45,873 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:updateIPs:290] [IP-UPDATED] namespace: public, service: mall@@joyday, ips: 10.6.33.23:8064_true,10.6.33.23:8066_true,  2024-08-03 16:53:45,873 DEBUG [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:recalculateChecksum:549] service to json: {"invalidIPCount":0,"name":"mall@@joyday","ipCount":2,"owners":[],"protectThreshold":0.0,"clusters":[{"healthChecker":{},"defIPPort":80,"defCkport":80,"name":"beijing","useIPPort4Check":true,"sitegroup":""}]}  2024-08-03 16:53:45,873 DEBUG [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl$Notifier:handle:447] [NACOS-DISTRO] datum change notified, key: com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday, listener count: 1, action: CHANGE  2024-08-03 16:53:46,566 DEBUG [http-nio-8848-exec-8] [com.alibaba.nacos.naming.controllers.InstanceController:beat:494] [CLIENT-BEAT] full arguments: beat: null, serviceName: mall@@joyday  2024-08-03 16:53:46,878 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:lambda$onApplicationEvent$1:127] mall@@joyday is changed, add it to push queue.  2024-08-03 16:53:46,879 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:lambda$onApplicationEvent$1:166] serviceName: mall@@joyday changed, schedule push for: 10.6.33.23:53206, agent: Nacos-Java-Client:v1.4.2, key: 10.6.33.23,53206,374291714306500  2024-08-03 16:53:46,879 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:udpPush:614] send udp packet: 10.6.33.23,53206,374291714306500  2024-08-03 16:53:46,880 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:lambda$onApplicationEvent$1:166] serviceName: mall@@joyday changed, schedule push for: 10.6.33.23:62806, agent: Nacos-Java-Client:v1.4.2, key: 10.6.33.23,62806,374291714306500  2024-08-03 16:53:46,881 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:udpPush:614] send udp packet: 10.6.33.23,62806,374291714306500  2024-08-03 16:53:46,885 INFO [com.alibaba.nacos.naming.push.receiver] [com.alibaba.nacos.naming.push.PushService$Receiver:run:687] received ack: {"type": "push-ack", "lastRefTime":"374291714306500", "data":""} from: 10.6.33.23:62806, cost: 4 ms, unacked: 1, total push: 4  2024-08-03 16:53:46,885 INFO [com.alibaba.nacos.naming.push.receiver] [com.alibaba.nacos.naming.push.PushService$Receiver:run:687] received ack: {"type": "push-ack", "lastRefTime":"374291714306500", "data":""} from: 10.6.33.23:53206, cost: 6 ms, unacked: 0, total push: 4  2024-08-03 16:53:47,494 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.core.ServiceManager:createServiceIfAbsent:492] createServiceIfAbsent end getClusterMap {beijing=com.alibaba.nacos.naming.core.Cluster@f27590dd}  2024-08-03 16:53:47,494 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.core.ServiceManager:addInstance:653]  addInstance key:com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday  2024-08-03 16:53:47,495 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.core.ServiceManager:addInstance:656]  addInstance ,serviceMap:{public={mall@@joyday=Service{name='mall@@joyday', protectThreshold=0.0, appName='null', groupName='mall', metadata={}}}}  2024-08-03 16:53:47,495 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.core.ServiceManager:updateIpAddresses:809]  updateIpAddresses before  currentIPs:[10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing],instanceMap:{10.6.33.23:8064:unknown:beijing=10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing=10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing}  2024-08-03 16:53:47,496 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.core.ServiceManager:updateIpAddresses:842]  updateIpAddresses after  currentIPs:[10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing],instanceMap:{10.6.33.23:8064:unknown:beijing=10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing=10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing}  2024-08-03 16:53:47,496 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.core.ServiceManager:addInstance:664]  addInstance after addIpAddresses new instanceList:[10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing]  2024-08-03 16:53:47,496 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:put:108]  distro put key:com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday,value:{"instanceList":[{"instanceId":"10.6.33.23#8064#beijing#mall@@joyday","ip":"10.6.33.23","port":8064,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"dubbo.metadata-service.urls":"[ \"dubbo://10.6.33.23:20880/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=joyday&bind.ip=10.6.33.23&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=joyday&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=38352&qos.enable=false&release=2.7.8&revision=2.2.6.RELEASE&side=provider×tamp=1722675134397&version=1.0.0\" ]","dubbo.metadata.revision":"0","preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722675226566,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000},{"instanceId":"10.6.33.23#8066#beijing#mall@@joyday","ip":"10.6.33.23","port":8066,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"dubbo.metadata-service.urls":"[ \"dubbo://10.6.33.23:20881/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=joyday&bind.ip=10.6.33.23&bind.port=20881&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=joyday&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=44484&qos.enable=false&release=2.7.8&revision=2.2.6.RELEASE&side=provider×tamp=1722675226758&version=1.0.0\" ]","dubbo.metadata.revision":"0","preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722675227493,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}]}  2024-08-03 16:53:47,496 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:onPut:132] createServiceIfAbsent start dataStore {com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday=com.alibaba.nacos.naming.consistency.Datum@36aea586}  2024-08-03 16:53:47,497 INFO [http-nio-8848-exec-9] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl:onPut:141] createServiceIfAbsent end dataStore {com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday=com.alibaba.nacos.naming.consistency.Datum@6ee0d505}  2024-08-03 16:53:47,497 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:onChange:178] [NACOS-RAFT] datum service is changed, key: com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday, value: {"instanceList":[{"instanceId":"10.6.33.23#8064#beijing#mall@@joyday","ip":"10.6.33.23","port":8064,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"dubbo.metadata-service.urls":"[ \"dubbo://10.6.33.23:20880/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=joyday&bind.ip=10.6.33.23&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=joyday&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=38352&qos.enable=false&release=2.7.8&revision=2.2.6.RELEASE&side=provider×tamp=1722675134397&version=1.0.0\" ]","dubbo.metadata.revision":"0","preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722675226566,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000},{"instanceId":"10.6.33.23#8066#beijing#mall@@joyday","ip":"10.6.33.23","port":8066,"weight":1.0,"healthy":true,"enabled":true,"ephemeral":true,"clusterName":"beijing","serviceName":"mall@@joyday","metadata":{"dubbo.metadata-service.urls":"[ \"dubbo://10.6.33.23:20881/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=joyday&bind.ip=10.6.33.23&bind.port=20881&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=joyday&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=44484&qos.enable=false&release=2.7.8&revision=2.2.6.RELEASE&side=provider×tamp=1722675226758&version=1.0.0\" ]","dubbo.metadata.revision":"0","preserved.register.source":"SPRING_CLOUD"},"lastBeat":1722675227493,"marked":false,"app":"unknown","instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"ipDeleteTimeout":30000}]}  2024-08-03 16:53:47,497 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:updateIPs:237] updateIPs before, instances: [10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing], ephemeral: true  2024-08-03 16:53:47,497 INFO [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:updateIPs:290] [IP-UPDATED] namespace: public, service: mall@@joyday, ips: 10.6.33.23:8064_true,10.6.33.23:8066_true,  2024-08-03 16:53:47,498 DEBUG [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.core.Service:recalculateChecksum:549] service to json: {"invalidIPCount":0,"name":"mall@@joyday","ipCount":2,"owners":[],"protectThreshold":0.0,"clusters":[{"healthChecker":{},"defIPPort":80,"defCkport":80,"name":"beijing","useIPPort4Check":true,"sitegroup":""}]}  2024-08-03 16:53:47,498 DEBUG [com.alibaba.nacos.naming.distro.notifier.0] [com.alibaba.nacos.naming.consistency.ephemeral.distro.DistroConsistencyServiceImpl$Notifier:handle:447] [NACOS-DISTRO] datum change notified, key: com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday, listener count: 1, action: CHANGE  2024-08-03 16:53:47,674 DEBUG [com.alibaba.nacos.naming.service.worker.0] [com.alibaba.nacos.naming.core.Service:recalculateChecksum:549] service to json: {"invalidIPCount":0,"name":"mall@@joyday","ipCount":2,"owners":[],"protectThreshold":0.0,"clusters":[{"healthChecker":{},"defIPPort":80,"defCkport":80,"name":"beijing","useIPPort4Check":true,"sitegroup":""}]}  2024-08-03 16:53:48,501 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:lambda$onApplicationEvent$1:127] mall@@joyday is changed, add it to push queue.  2024-08-03 16:53:48,501 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:lambda$onApplicationEvent$1:166] serviceName: mall@@joyday changed, schedule push for: 10.6.33.23:53206, agent: Nacos-Java-Client:v1.4.2, key: 10.6.33.23,53206,374293336465400  2024-08-03 16:53:48,501 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:udpPush:614] send udp packet: 10.6.33.23,53206,374293336465400  2024-08-03 16:53:48,502 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:lambda$onApplicationEvent$1:166] serviceName: mall@@joyday changed, schedule push for: 10.6.33.23:62806, agent: Nacos-Java-Client:v1.4.2, key: 10.6.33.23,62806,374293336465400  2024-08-03 16:53:48,502 INFO [com.alibaba.nacos.naming.push.udpSender.0] [com.alibaba.nacos.naming.push.PushService:udpPush:614] send udp packet: 10.6.33.23,62806,374293336465400  2024-08-03 16:53:48,504 INFO [com.alibaba.nacos.naming.push.receiver] [com.alibaba.nacos.naming.push.PushService$Receiver:run:687] received ack: {"type": "push-ack", "lastRefTime":"374293336465400", "data":""} from: 10.6.33.23:53206, cost: 3 ms, unacked: 1, total push: 6  2024-08-03 16:53:48,505 INFO [com.alibaba.nacos.naming.push.receiver] [com.alibaba.nacos.naming.push.PushService$Receiver:run:687] received ack: {"type": "push-ack", "lastRefTime":"374293336465400", "data":""} from: 10.6.33.23:62806, cost: 3 ms, unacked: 0, total push: 6  2024-08-03 16:53:51,570 DEBUG [http-nio-8848-exec-4] [com.alibaba.nacos.naming.controllers.InstanceController:beat:494] [CLIENT-BEAT] full arguments: beat: null, serviceName: mall@@joyday  2024-08-03 16:53:52,685 DEBUG [com.alibaba.nacos.naming.service.worker.0] [com.alibaba.nacos.naming.core.Service:recalculateChecksum:549] service to json: {"invalidIPCount":0,"name":"mall@@joyday","ipCount":2,"owners":[],"protectThreshold":0.0,"clusters":[{"healthChecker":{},"defIPPort":80,"defCkport":80,"name":"beijing","useIPPort4Check":true,"sitegroup":""}]} 

 updateIpAddresses after  currentIPs:[10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing],instanceMap:{10.6.33.23:8064:unknown:beijing=10.6.33.23:8064:unknown:beijing_1.0_true_false_beijing, 10.6.33.23:8066:unknown:beijing=10.6.33.23:8066:unknown:beijing_1.0_true_false_beijing}

可以看到经过updateIpAddresses  多了一个实例,

最终写入distro后,也会多了一个实例

distro put key:com.alibaba.nacos.naming.iplist.ephemeral.public##mall@@joyday,value:

{     "instanceList":[         {             "instanceId":"10.6.33.23#8064#beijing#mall@@joyday",             "ip":"10.6.33.23",             "port":8064,             "weight":1,             "healthy":true,             "enabled":true,             "ephemeral":true,             "clusterName":"beijing",             "serviceName":"mall@@joyday",             "metadata":{                 "dubbo.metadata-service.urls":"[ "dubbo://10.6.33.23:20880/com.alibaba.cloud.dubbo.service.DubboMetadataService?anyhost=true&application=joyday&bind.ip=10.6.33.23&bind.port=20880&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=joyday&interface=com.alibaba.cloud.dubbo.service.DubboMetadataService&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs&pid=38352&qos.enable=false&release=2.7.8&revision=2.2.6.RELEASE&side=provider×tamp=1722675134397&version=1.0.0" ]",                 "dubbo.metadata.revision":"0",                 "preserved.register.source":"SPRING_CLOUD"             },             "lastBeat":1722675221548,             "marked":false,             "app":"unknown",             "instanceHeartBeatInterval":5000,             "instanceHeartBeatTimeOut":15000,             "ipDeleteTimeout":30000         },         {             "instanceId":"10.6.33.23#8066#beijing#mall@@joyday",             "ip":"10.6.33.23",             "port":8066,             "weight":1,             "healthy":true,             "enabled":true,             "ephemeral":true,             "clusterName":"beijing",             "serviceName":"mall@@joyday",             "metadata":{                 "preserved.register.source":"SPRING_CLOUD"             },             "lastBeat":1722675225870,             "marked":false,             "app":"unknown",             "instanceHeartBeatInterval":5000,             "instanceHeartBeatTimeOut":15000,             "ipDeleteTimeout":30000         }     ] }

三、注册表数据结构

1.数据结构思维导图

相关内容

热门资讯

黑科技app!aapoker辅... 黑科技app!aapoker辅助器怎么用(ai辅助)太坑了有挂(我来教教你黑科技规律)-哔哩哔哩aa...
黑科技脚本"德扑之星... 黑科技脚本"德扑之星软件辅牌器"wopoker辅助真的假的(都是是真的有挂)-哔哩哔哩1、实时德扑之...
黑科技游戏(aapoker辅助... 黑科技游戏(aapoker辅助工具存在吗)外挂黑科技辅助下载(透视)本来存在有挂(黑科技解说)-哔哩...
黑科技透明挂!wpk辅助神器,... 黑科技透明挂!wpk辅助神器,智星德州菠萝怎么开挂,可靠教程(有挂了解)-哔哩哔哩1、智星德州菠萝怎...
黑科技教程!微扑克发牌为什么这... 黑科技教程!微扑克发牌为什么这么离谱(黑科技)太坑了存在有挂(总结教程黑科技解说)-哔哩哔哩;1.微...
黑科技辅助"云扑克辅... 黑科技辅助"云扑克辅助透视"aapoker安卓怎么下载(竟然存在有挂)-哔哩哔哩;1、aapoker...
黑科技辅助(wpkai透视外挂... 黑科技辅助(wpkai透视外挂售卖)外挂透视辅助教程(透视)本来真的有挂(黑科技方法)-哔哩哔哩1、...
黑科技机器人!wepoke黑科... 黑科技机器人!wepoke黑科技功能,德扑之星作弊事件,详细教程(有挂辅助挂)-哔哩哔哩;是一款可以...
黑科技存在!微扑克ai机器人打... 黑科技存在!微扑克ai机器人打德州(ai代打)太坑了存在有挂(攻略教程黑科技方法)-哔哩哔哩;微扑克...
黑科技挂"aa扑克平... 黑科技挂"aa扑克平台的机制"wpk透明挂(切实有挂)-哔哩哔哩;1、用户打开应用后不用登录就可以直...