Eureka 学习笔记4:客户端 DiscoveryClient

本文介绍了Eureka客户端的核心组件,包括cacheRefreshTask、heartbeatTask和instanceInfoReplicator的工作原理。详细讲解了它们的默认配置、超时后的策略以及如何向服务端注册和续约实例。此外,还提到了StatusChangeListener在实例状态更新时的作用。
摘要由CSDN通过智能技术生成

版本 awsVersion = ‘1.11.277’

DiscoveryClient # cacheRefreshTask

// 配置shouldFetchRegistry
if (clientConfig.shouldFetchRegistry()) {
   
    // 配置client.refresh.interval
    int registryFetchIntervalSeconds = clientConfig
        .getRegistryFetchIntervalSeconds();
    // 配置expBackOffBound
    int expBackOffBound = clientConfig
        .getCacheRefreshExecutorExponentialBackOffBound();

    cacheRefreshTask = new TimedSupervisorTask(
        "cacheRefresh",
        scheduler,
        cacheRefreshExecutor,
        registryFetchIntervalSeconds,
        TimeUnit.SECONDS,
        expBackOffBound,
        new CacheRefreshThread()
    );

    scheduler.schedule(
        cacheRefreshTask,
        registryFetchIntervalSeconds, TimeUnit.SECONDS);
}

shouldFetchRegistry 指定是否从服务端拉取注册列表,默认 true

client.refresh.interval 指定从服务端拉取注册列表的时间间隔,默认 30s

client.cacheRefresh.exponentialBackOffBound 指定从服务端拉取注册列表的最大时间间隔,默认 10

注1:当从服务端拉取注册列表的请求超时(即 TimedSupervisorTask 捕获 TimeoutException 异常时),下一次拉取的时间间隔会成倍递增,递增后的时间间隔不能超过 client.cacheRefresh.exponentialBackOffBoundclient.refresh.interval 的乘积(即拉取的时间间隔最大不能超过 10x30=300s)

注2
supervisor

/ˈsuːpəvaɪzə®/

/ˈsuːpərvaɪzər/
n.
监督人;主管人;指导者

注3
exponential

/ˌekspəˈnenʃl/

/ˌekspəˈnenʃl/
adj.
指数的;幂的;越来越快的;由指数表示的
n.
指数


DiscoveryClient # heartbeatTask

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值