标签:ase cli csdn cloud head toc processor eve ack
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 数据模型
表1:Eureka 数据结构
框架 |
集群(框架) |
服务应用 |
服务集群 |
服务实例 |
租约管理 |
Spring-Cloud |
-- |
(serviceId) |
-- |
ServiceInstance |
-- |
Nacos |
Server |
Service |
Cluster |
Instance |
-- |
Eureka |
(serviceUrl) |
Application(appName) |
-- |
InstanceInfo(id) |
Lease |
Ribbon |
-- |
-- |
-- |
Server |
-- |
2. 服务注册
图1:Eureka 服务实例注册时序图
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}
图2:Eureka 心跳机制
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)服务发现源码分析
标签:ase cli csdn cloud head toc processor eve ack
原文地址:https://www.cnblogs.com/binarylei/p/11610885.html