Eureka重要对象简介
程序员文章站
2023-11-09 16:08:22
在进行分析EurekaClient和EurekaServer之间通信的源码之前,我们首先需要熟悉一下几个实体类 这个类代表着EurekaClient实例,客户端向服务端请求注册时就会携带着这个实例,这个实例中包含了当前客户端的一些基本信息: 这个枚举中包含了客户端可能存在的状态 这个类是服务端用来保 ......
在进行分析eurekaclient和eurekaserver之间通信的源码之前,我们首先需要熟悉一下几个实体类
instanceinfo
这个类代表着eurekaclient实例,客户端向服务端请求注册时就会携带着这个实例,这个实例中包含了当前客户端的一些基本信息:
private volatile string instanceid; private volatile string appname; @auto private volatile string appgroupname; private volatile string ipaddr; private static final string sid_default = "na"; @deprecated private volatile string sid = sid_default; private volatile int port = default_port; private volatile int secureport = default_secure_port; @auto private volatile string homepageurl; @auto private volatile string statuspageurl; @auto private volatile string healthcheckurl; @auto private volatile string securehealthcheckurl; @auto private volatile string vipaddress; @auto private volatile string securevipaddress; @xstreamomitfield private string statuspagerelativeurl; @xstreamomitfield private string statuspageexpliciturl; @xstreamomitfield private string healthcheckrelativeurl; @xstreamomitfield private string healthchecksecureexpliciturl; @xstreamomitfield private string vipaddressunresolved; @xstreamomitfield private string securevipaddressunresolved; @xstreamomitfield private string healthcheckexpliciturl; @deprecated private volatile int countryid = default_country_id; // defaults to us private volatile boolean issecureportenabled = false; private volatile boolean isunsecureportenabled = true; private volatile datacenterinfo datacenterinfo; private volatile string hostname; private volatile instancestatus status = instancestatus.up; private volatile instancestatus overriddenstatus = instancestatus.unknown; @xstreamomitfield private volatile boolean isinstanceinfodirty = false; private volatile leaseinfo leaseinfo; @auto private volatile boolean iscoordinatingdiscoveryserver = boolean.false; @xstreamalias("metadata") private volatile map<string, string> metadata; @auto private volatile long lastupdatedtimestamp; @auto private volatile long lastdirtytimestamp; @auto private volatile actiontype actiontype; @auto private volatile string asgname; private string version = version_unknown;
instancestatus
这个枚举中包含了客户端可能存在的状态
up, down, starting, out_of_service, unknown;
lease
这个类是服务端用来保存客户端的租约信息的,其中holder中持有的就是instanceinfo
对象
// 租约过期时间 public static final int default_duration_in_secs = 90; //客户端实例 private t holder; //服务下线时间 private long evictiontimestamp; //注册起始时间 private long registrationtimestamp; //取消注册时间 private long serviceuptimestamp; // 最后更新时间 private volatile long lastupdatetimestamp; //租约持续时间 private long duration;
peereurekanode
这个对象代表着集群节点信息
/** * 服务地址 */ private final string serviceurl; /** * eureka-server 配置 */ private final eurekaserverconfig config; /** * 批任务同步最大延迟 */ private final long maxprocessingdelayms; /** * 应用实例注册表 */ private final peerawareinstanceregistry registry; /** * 目标 host */ private final string targethost; /** * 集群 eurekahttpclient */ private final httpreplicationclient replicationclient; /** * 批量任务分发器 */ private final taskdispatcher<string, replicationtask> batchingdispatcher; /** * 单任务分发器 */ private final taskdispatcher<string, replicationtask> nonbatchingdispatcher;
eurekahttpclient
这个是eureka客户端与服务端通信的接口
public interface eurekahttpclient { eurekahttpresponse<void> register(instanceinfo info); eurekahttpresponse<void> cancel(string appname, string id); eurekahttpresponse<instanceinfo> sendheartbeat(string appname, string id, instanceinfo info, instancestatus overriddenstatus); eurekahttpresponse<void> statusupdate(string appname, string id, instancestatus newstatus, instanceinfo info); eurekahttpresponse<void> deletestatusoverride(string appname, string id, instanceinfo info); eurekahttpresponse<applications> getapplications(string... regions); eurekahttpresponse<applications> getdelta(string... regions); eurekahttpresponse<applications> getvip(string vipaddress, string... regions); eurekahttpresponse<applications> getsecurevip(string securevipaddress, string... regions); eurekahttpresponse<application> getapplication(string appname); eurekahttpresponse<instanceinfo> getinstance(string appname, string id); eurekahttpresponse<instanceinfo> getinstance(string id); void shutdown(); }
本文由博客一文多发平台 openwrite 发布!
上一篇: 详解WordPress开发中用于获取分类及子页面的函数用法
下一篇: Centos5给/根分区扩容