Eureka 系列(02)服务发现源码分析
Posted binarylei
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Eureka 系列(02)服务发现源码分析相关的知识,希望对你有一定的参考价值。
Eureka 系列(02)服务发现源码分析
[TOC]
在上一篇文章 Eureka 系列(02)客户端源码分析 中对客户端服务发现与
Eureka 一致性协议:
Eureka 是 AP 模型
消息广播:
Eureka源码解析 https://blog.csdn.net/u012394095/article/category/9279158
https://blog.csdn.net/u011834741/article/details/54694045
Eureka 集群发现 https://www.jianshu.com/p/4de50f536354
Eureka 数据同步 https://www.jianshu.com/p/4de50f536354
Eureka 服务启动过程 https://my.oschina.net/JackieRiver/blog/1925978
Eureka常见问题解答 https://cloud.tencent.com/developer/news/275633
Eureka架构 https://segmentfault.com/a/1190000019851462
https://www.cnblogs.com/theRhyme/p/10313299.html
1. Eureka 数据模型
框架 | 集群(框架) | 服务应用 | 服务集群 | 服务实例 | 租约管理 |
---|---|---|---|---|---|
Spring-Cloud | -- | (serviceId) | -- | ServiceInstance | -- |
Nacos | Server | Service | Cluster | Instance | -- |
Eureka | (serviceUrl) | Application(appName) | -- | InstanceInfo(id) | Lease |
Ribbon | -- | -- | -- | Server | -- |
2. 服务注册
sequenceDiagram
participant ApplicationResource
participant InstanceRegistry
participant PeerAwareInstanceRegistryImpl
participant AbstractInstanceRegistry
participant PeerEurekaNode
note over ApplicationResource: POST:/euraka/apps/{appName}<br/>addInstance(instanceInfo,isReplication)
ApplicationResource ->> InstanceRegistry: 1. register
InstanceRegistry ->> InstanceRegistry: 2.1 publishEvent
InstanceRegistry ->> PeerAwareInstanceRegistryImpl: 2.2 register(instanceInfo,isReplication)
PeerAwareInstanceRegistryImpl ->> AbstractInstanceRegistry: 3.1 register(instanceInfo,leaseDuration,isReplication)
PeerAwareInstanceRegistryImpl ->> PeerAwareInstanceRegistryImpl: 3.2 replicateInstanceActionsToPeers
PeerAwareInstanceRegistryImpl ->> PeerEurekaNode: 4. register(instanceInfo) -> POST:/euraka/apps/{appName}
sequenceDiagram
participant InstanceResource
participant InstanceRegistry
participant PeerAwareInstanceRegistryImpl
participant AbstractInstanceRegistry
participant PeerEurekaNode
note over InstanceResource: PUT:/euraka/apps/{appName}/{id}<br/>renewLease
InstanceResource ->> InstanceRegistry : 1. renew(appName,id,isReplication)
InstanceRegistry ->> InstanceRegistry : 2.1 publishEvent(EurekaInstanceRenewedEvent)
InstanceRegistry ->> PeerAwareInstanceRegistryImpl : 2.2 renew(appName,id,isReplication)
PeerAwareInstanceRegistryImpl ->> AbstractInstanceRegistry : 3.1 renew(appName,id,isReplication)
PeerAwareInstanceRegistryImpl ->> PeerAwareInstanceRegistryImpl : 3.2 replicateToPeers
PeerAwareInstanceRegistryImpl ->> PeerEurekaNode : 4. heartbeat -> PUT:/euraka/apps/{appName}/{id}
sequenceDiagram
participant PeerEurekaNode
participant batchingTaskDispatcher
participant BatchWorkerRunnable
participant nonBatchingDispatcher
participant SingleTaskWorkerRunnable
participant ReplicationTaskProcessor
participant JerseyReplicationClient
loop 批量发送处理:
PeerEurekaNode ->> batchingTaskDispatcher : register/cancel/heartbeat/statusUpdate/deleteStatusOverride
batchingTaskDispatcher ->> BatchWorkerRunnable : process(List<ReplicationTask> tasks)
BatchWorkerRunnable ->> JerseyReplicationClient : submitBatchUpdates -> `POST: peerreplication/batch`
end
loop 单个发送处理:
PeerEurekaNode ->> nonBatchingDispatcher : statusUpdate
nonBatchingDispatcher ->> SingleTaskWorkerRunnable : process(ReplicationTask task)
SingleTaskWorkerRunnable ->> JerseyReplicationClient : statusUpdate -> `PUT: asg/{asgName}/status`
end
以上是关于Eureka 系列(02)服务发现源码分析的主要内容,如果未能解决你的问题,请参考以下文章