Eureka重要对象简介
2019-10-25 06:43:07来源:博客园 阅读 ()
Eureka重要对象简介
在进行分析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 发布!
原文链接:https://www.cnblogs.com/zhixiang-org-cn/p/11710793.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇:Mybatis学习 三
- 通过与C++程序对比,彻底搞清楚JAVA的对象拷贝 2020-06-11
- Java笔记:集合 2020-06-10
- Java基础复习——类和对象 2020-06-09
- 2020最新IDEA插件大集合,一款能帮助你写代码的工具是多么重 2020-06-09
- 计算机基础到底是哪些基础?为什么很重要! 2020-06-08
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash