一、客户端主动注册实例流程
1.首先客户端必要引入服务发现包
- <groupId>com.alibaba.cloud</groupId>
- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
- <version>2.2.6.RELEASE</version>
复制代码 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<String, String> params, Map<String, String> body, List<String> 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<Service> {
-
- /**
- * Map(namespace, Map(group::serviceName, Service)). 真正的注册表
- */
- private final Map<String, Map<String, Service>> serviceMap = new ConcurrentHashMap<>();
-
- private final LinkedBlockingDeque<ServiceKey> 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
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.
注意在这里,会给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.数据布局思维导图
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |