springcloud系列-eureka源码解析

发布 : 2019-05-14 分类 : springcloud 浏览 :

eureka-server使用

参考来源:springcloud-netflix
1、引入eureka-server的jar包

1
2
3
4
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

2、由于eureka-server也是一个springboot的应用,所以需要引入web包

1
2
3
4
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

3、启动eureka-server

1
2
3
4
5
6
7
8
9
@SpringBootApplication
@EnableEurekaServer
public class Application {

public static void main(String[] args) {
new SpringApplicationBuilder(Application.class).web(true).run(args);
}

}

4、这里有一点需要注意下,需要将eureka的endpoint暴露出来,所以需要在项目中引入actuator包

1
2
3
4
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

standalone mode

  • 这个是单点模式,eureka的集群模式理论上两两互相注册的方式,这里就启动一个服务端,我们看下配置
    application.yml文件内容:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    server:
    port: 8761

    eureka:
    instance:
    hostname: localhost
    client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
    defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

peer awareness mode

application.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
server:
port: 8083
host: localhost
spring:
application:
name: eureka-server
profiles: peer1
eureka:
instance:
hostname: eureka-server1
prefer-ip-address: true
instance-id: ${spring.cloud.client.ipAddress}:${server.port}
lease-renewal-interval-in-seconds: 5
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://${server.host}:8084/eureka/,http://${server.host}:8085/eureka/
---
server:
port: 8084
host: localhost
spring:
application:
name: eureka-server
profiles: peer2
eureka:
instance:
hostname: eureka-server2
prefer-ip-address: true
instance-id: ${spring.cloud.client.ipAddress}:${server.port}
lease-renewal-interval-in-seconds: 5
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://${server.host}:8084/eureka/,http://${server.host}:8085/eureka/

---
server:
port: 8085
host: localhost
spring:
application:
name: eureka-server
profiles: peer3
eureka:
instance:
hostname: eureka-server3
prefer-ip-address: true
instance-id: ${spring.cloud.client.ipAddress}:${server.port}
lease-renewal-interval-in-seconds: 5
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://${server.host}:8084/eureka/,http://${server.host}:8085/eureka/

  • 在启动的时候,用如下命令java -jar -Dspring.profiles.active=peer1 xxx.jar即可。启动三个节点,互相注册的方式。
  • 官网建议用ip进行注册,而不是用hostname,开启配置:eureka.instance.preferIpAddress=true
    1
    2
    3
    4
    5
    /**
    * Flag to say that, when guessing a hostname, the IP address of the server should be
    * used in prference to the hostname reported by the OS.
    */
    private boolean preferIpAddress = false;

源码解析

说明:这里解析的是springcloud-netflix-eureka-server的源码,底层会涉及eureka的自身源码。
对于这个server包,其中自动引入了两个包:eureka-client/springcloud-netflix-eureka-client这是核心的pom文件中内容。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-client</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.eureka</groupId>
<artifactId>eureka-core</artifactId>
<exclusions>
<exclusion>
<artifactId>blitz4j</artifactId>
<groupId>com.netflix.blitz4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.netflix.archaius</groupId>
<artifactId>archaius-core</artifactId>
</dependency>

netflix-client包

这个pom文件中也引入了client包。
在springboot启动之初,依据springboot的spi机制,也会加载/META-INF/spring.factories文件中的类:

1
2
3
4
5
6
7
8
9
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.netflix.eureka.config.EurekaClientConfigServerAutoConfiguration,\
org.springframework.cloud.netflix.eureka.config.EurekaDiscoveryClientConfigServiceAutoConfiguration,\
org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration,\
org.springframework.cloud.netflix.ribbon.eureka.RibbonEurekaAutoConfiguration,\
org.springframework.cloud.netflix.eurEurekaRegistryAvailableEventeka.EurekaDiscoveryClientConfiguration

org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.cloud.netflix.eureka.config.EurekaDiscoveryClientConfigServiceBootstrapConfiguration

EurekaClientConfigServerAutoConfiguration

这个是加载一些配置项

EurekaDiscoveryClientConfigServiceAutoConfiguration

DiscoveryClient

构造函数里定义了heartbeatExecutor和cacheRefreshExecutor
看initScheduledTasks方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* Initializes all scheduled tasks.
*/
private void initScheduledTasks() {
if (clientConfig.shouldFetchRegistry()) {
// registry cache refresh timer
int registryFetchIntervalSeconds = clientConfig.getRegistryFetchIntervalSeconds();
int expBackOffBound = clientConfig.getCacheRefreshExecutorExponentialBackOffBound();
//CacheRefreshThread刷新缓存。->refreshRegistry()方法
scheduler.schedule(
new TimedSupervisorTask(
"cacheRefresh",
scheduler,
cacheRefreshExecutor,
registryFetchIntervalSeconds,
TimeUnit.SECONDS,
expBackOffBound,
new CacheRefreshThread()
),
registryFetchIntervalSeconds, TimeUnit.SECONDS);
}

if (clientConfig.shouldRegisterWithEureka()) {
int renewalIntervalInSecs = instanceInfo.getLeaseInfo().getRenewalIntervalInSecs();
int expBackOffBound = clientConfig.getHeartbeatExecutorExponentialBackOffBound();
logger.info("Starting heartbeat executor: " + "renew interval is: " + renewalIntervalInSecs);

// Heartbeat timer。 HeartbeatThread->renew()方法
scheduler.schedule(
new TimedSupervisorTask(
"heartbeat",
scheduler,
heartbeatExecutor,
renewalIntervalInSecs,
TimeUnit.SECONDS,
expBackOffBound,
new HeartbeatThread()
),
renewalIntervalInSecs, TimeUnit.SECONDS);

// InstanceInfo replicator
instanceInfoReplicator = new InstanceInfoReplicator(
this,
instanceInfo,
clientConfig.getInstanceInfoReplicationIntervalSeconds(),
2); // burstSize

//定义了一个listener,监听注册节点状态的变化。
statusChangeListener = new ApplicationInfoManager.StatusChangeListener() {
@Override
public String getId() {
return "statusChangeListener";
}

@Override
public void notify(StatusChangeEvent statusChangeEvent) {
if (InstanceStatus.DOWN == statusChangeEvent.getStatus() ||
InstanceStatus.DOWN == statusChangeEvent.getPreviousStatus()) {
// log at warn level if DOWN was involved
logger.warn("Saw local status change event {}", statusChangeEvent);
} else {
logger.info("Saw local status change event {}", statusChangeEvent);
}
instanceInfoReplicator.onDemandUpdate();
}
};

if (clientConfig.shouldOnDemandUpdateStatusChange()) {
applicationInfoManager.registerStatusChangeListener(statusChangeListener);
}

instanceInfoReplicator.start(clientConfig.getInitialInstanceInfoReplicationIntervalSeconds());
} else {
logger.info("Not registering with Eureka server per configuration");
}
}

server包

1
2
@SpringBootApplication
@EnableEurekaServer
  • 对于EnableEurekaServer没太多的内容
    1
    2
    3
    4
    5
    6
    7
    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @Import(EurekaServerMarkerConfiguration.class)
    public @interface EnableEurekaServer {

    }

EurekaServerMarkerConfiguration.java:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
* Responsible for adding in a marker bean to activate
* {@link EurekaServerAutoConfiguration}
*
* @author Biju Kunjummen
*/
@Configuration
public class EurekaServerMarkerConfiguration {

@Bean
public Marker eurekaServerMarkerBean() {
return new Marker();
}

class Marker {
}
}

  • 核心是springbootApplication,会进行自动化装配,对于eureka-server中的/META-INF/spring.factories文件自动装配。
    1
    2
    rg.springframework.boot.autoconfigure.EnableAutoConfiguration=\
    org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration

我们核心看下EurekaServerAutoConfiguration.java类


EurekaServerAutoConfiguration

  • 先来看下这个类涉及到的注解:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    @Configuration
    @Import(EurekaServerInitializerConfiguration.class)
    @ConditionalOnBean(EurekaServerMarkerConfiguration.Marker.class)
    @EnableConfigurationProperties({ EurekaDashboardProperties.class,
    InstanceRegistryProperties.class })
    @PropertySource("classpath:/eureka/server.properties")
    public class EurekaServerAutoConfiguration extends WebMvcConfigurerAdapter {
    ........
    }

1、@Configuration这个注解配合@Bean使用。所以我们看下这个类中有哪些bean被实例化,基本整个类的代码内容都是在实例化一些对象:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//这个创建了一个HasFeatures对象,这个对象暂时不清楚做什么,后面再看,基本是有个list。
@Bean
public HasFeatures eurekaServerFeature() {
return HasFeatures.namedFeature("Eureka Server",
EurekaServerAutoConfiguration.class);
}


@Configuration
protected static class EurekaServerConfigBeanConfiguration {
//EurekaServerConfig是一个接口,实现类是EurekaServerConfigBean
//EurekaServerConfigBean里面的属性默认是取配置文件的eureka.server.xxxxx
//EurekaServerConfigBean这个就是eureka-server的核心配置类。
@Bean
@ConditionalOnMissingBean
public EurekaServerConfig eurekaServerConfig(EurekaClientConfig clientConfig) {
EurekaServerConfigBean server = new EurekaServerConfigBean();
if (clientConfig.shouldRegisterWithEureka()) {
// Set a sensible default if we are supposed to replicate
//这里只是设置下目前的一个注册属性。
server.setRegistrySyncRetries(5);
}
return server;
}
}

//实例化EurekaController,这个就是集群的控制台。就是你敲任何一个ip:port的时候跳出来的控制台页面。
//对于EurekaController,看到他读取了json文件中的配置,这个配置也是自动装配,spring-configuration-metedata.json,可以看到对应的类是EurekaDashboardProperties。
//EurekaDashboardProperties这个类里引用了:@ConfigurationProperties("eureka.dashboard"),默认的path="/",enabled = true。
//所以,可以关闭控制台,对应的前缀就是eureka.dashboard.xxxx=???
@Bean
@ConditionalOnProperty(prefix = "eureka.dashboard", name = "enabled", matchIfMissing = true)
public EurekaController eurekaController() {
return new EurekaController(this.applicationInfoManager);
}

//这里引用到了eurekaServerConfig。这个在代码里进行了实例化。
//ServerCodecs是一个接口,实际上是server端支持两种编码方式:json和xml方式。至于是哪一种,需要看下eurekaServerConfig中有哪一种。
@Bean
public ServerCodecs serverCodecs() {
return new CloudServerCodecs(this.eurekaServerConfig);
}

//【1】
@Bean
public PeerAwareInstanceRegistry peerAwareInstanceRegistry(
ServerCodecs serverCodecs) {
//我们看下spring-cloud-netflix-eureka-server的源码,发现在他的pom文件中引入了eureka-client的包。同时也引入了spring-cloud-netflix-eureka-client这个包,由此可见,对于server来说,也是一个client的角色在整个集群中。
//DiscoveryClient实现了这个接口。CloudEurekaClient是这个类的子类
this.eurekaClient.getApplications(); // force initialization
return new InstanceRegistry(this.eurekaServerConfig, this.eurekaClientConfig,
serverCodecs, this.eurekaClient,
this.instanceRegistryProperties.getExpectedNumberOfRenewsPerMin(),
this.instanceRegistryProperties.getDefaultOpenForTrafficCount());
}

//这里返回了集群中每个节点的信息对象。进行封装
@Bean
@ConditionalOnMissingBean
public PeerEurekaNodes peerEurekaNodes(PeerAwareInstanceRegistry registry,
ServerCodecs serverCodecs) {
return new PeerEurekaNodes(registry, this.eurekaServerConfig,
this.eurekaClientConfig, serverCodecs, this.applicationInfoManager);
}

//Eureka服务的上下文对象。
@Bean
public EurekaServerContext eurekaServerContext(ServerCodecs serverCodecs,
PeerAwareInstanceRegistry registry, PeerEurekaNodes peerEurekaNodes) {
return new DefaultEurekaServerContext(this.eurekaServerConfig, serverCodecs,
registry, peerEurekaNodes, this.applicationInfoManager);
}

//Bootstrap实例化
@Bean
public EurekaServerBootstrap eurekaServerBootstrap(PeerAwareInstanceRegistry registry,
EurekaServerContext serverContext) {
return new EurekaServerBootstrap(this.applicationInfoManager,
this.eurekaClientConfig, this.eurekaServerConfig, registry,
serverContext);
}

/**
* Register the Jersey filter
*/
@Bean
public FilterRegistrationBean jerseyFilterRegistration(
javax.ws.rs.core.Application eurekaJerseyApp) {
FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(new ServletContainer(eurekaJerseyApp));
bean.setOrder(Ordered.LOWEST_PRECEDENCE);
bean.setUrlPatterns(
Collections.singletonList(EurekaConstants.DEFAULT_PREFIX + "/*"));

return bean;
}

/**
* Construct a Jersey {@link javax.ws.rs.core.Application} with all the resources
* required by the Eureka server.
*/
@Bean
public javax.ws.rs.core.Application jerseyApplication(Environment environment,
ResourceLoader resourceLoader) {

ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
false, environment);

// Filter to include only classes that have a particular annotation.
//
provider.addIncludeFilter(new AnnotationTypeFilter(Path.class));
provider.addIncludeFilter(new AnnotationTypeFilter(Provider.class));

// Find classes in Eureka packages (or subpackages)
//
Set<Class<?>> classes = new HashSet<Class<?>>();
for (String basePackage : EUREKA_PACKAGES) {
Set<BeanDefinition> beans = provider.findCandidateComponents(basePackage);
for (BeanDefinition bd : beans) {
Class<?> cls = ClassUtils.resolveClassName(bd.getBeanClassName(),
resourceLoader.getClassLoader());
classes.add(cls);
}
}

// Construct the Jersey ResourceConfig
//
Map<String, Object> propsAndFeatures = new HashMap<String, Object>();
propsAndFeatures.put(
// Skip static content used by the webapp
ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX,
EurekaConstants.DEFAULT_PREFIX + "/(fonts|images|css|js)/.*");

DefaultResourceConfig rc = new DefaultResourceConfig(classes);
rc.setPropertiesAndFeatures(propsAndFeatures);

return rc;
}

@Bean
public FilterRegistrationBean traceFilterRegistration(
@Qualifier("webRequestLoggingFilter") Filter filter) {
FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(filter);
bean.setOrder(Ordered.LOWEST_PRECEDENCE - 10);
return bean;
}

【1】关于EurekaClient类

2、EurekaServerInitializerConfiguration类
新起了一个线程,做bootstrap工作。这个类实现类SmartLifecycle接口,这个接口实现类Lifecycle接口。
LifeCycle定义Spring容器对象的生命周期,任何spring管理对象都可以实现该接口。然后,当ApplicationContext本身接收启动和停止信号(例如在运行时停止/重启场景)时,spring容器将在容器上下文中找出所有实现了LifeCycle及其子类接口的类,并一一调用它们实现的类。spring是通过委托给生命周期处理器LifecycleProcessor来实现这一点的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@Configuration
public class EurekaServerInitializerConfiguration
implements ServletContextAware, SmartLifecycle, Ordered {

@Override
public void start() {
new Thread(new Runnable() {
@Override
public void run() {
try {
//TODO: is this class even needed now?
EurekaServerBootstrap.contextInitialized(EurekaServerInitializerConfiguration.this.servletContext);
log.info("Started Eureka Server");

publish(new EurekaRegistryAvailableEvent(getEurekaServerConfig()));
EurekaServerInitializerConfiguration.this.running = true;
publish(new EurekaServerStartedEvent(getEurekaServerConfig()));
}
catch (Exception ex) {
// Help!
log.error("Could not initialize Eureka servlet context", ex);
}
}
}).start();
}
}

eureka.server.xxxx=xxxx参照EurekaServerConfigBean.java:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
public static final String PREFIX = "eureka.server";

private static final int MINUTES = 60 * 1000;

@Autowired(required = false)
PropertyResolver propertyResolver;

private String aWSAccessId;

private String aWSSecretKey;

private int eIPBindRebindRetries = 3;

private int eIPBindingRetryIntervalMs = 5 * MINUTES;

private int eIPBindingRetryIntervalMsWhenUnbound = 1 * MINUTES;

private boolean enableSelfPreservation = true;

private double renewalPercentThreshold = 0.85;

private int renewalThresholdUpdateIntervalMs = 15 * MINUTES;

private int peerEurekaNodesUpdateIntervalMs = 10 * MINUTES;

private int numberOfReplicationRetries = 5;

private int peerEurekaStatusRefreshTimeIntervalMs = 30 * 1000;

private int waitTimeInMsWhenSyncEmpty = 5 * MINUTES;

private int peerNodeConnectTimeoutMs = 200;

private int peerNodeReadTimeoutMs = 200;

private int peerNodeTotalConnections = 1000;

private int peerNodeTotalConnectionsPerHost = 500;

private int peerNodeConnectionIdleTimeoutSeconds = 30;

private long retentionTimeInMSInDeltaQueue = 3 * MINUTES;

private long deltaRetentionTimerIntervalInMs = 30 * 1000;

private long evictionIntervalTimerInMs = 60 * 1000;

private int aSGQueryTimeoutMs = 300;

private long aSGUpdateIntervalMs = 5 * MINUTES;

private long aSGCacheExpiryTimeoutMs = 10 * MINUTES; // defaults to longer than the
// asg update interval

private long responseCacheAutoExpirationInSeconds = 180;

private long responseCacheUpdateIntervalMs = 30 * 1000;

private boolean useReadOnlyResponseCache = true;

private boolean disableDelta;

private long maxIdleThreadInMinutesAgeForStatusReplication = 10;

private int minThreadsForStatusReplication = 1;

private int maxThreadsForStatusReplication = 1;

private int maxElementsInStatusReplicationPool = 10000;

private boolean syncWhenTimestampDiffers = true;

private int registrySyncRetries = 0;

private long registrySyncRetryWaitMs = 30 * 1000;

private int maxElementsInPeerReplicationPool = 10000;

private long maxIdleThreadAgeInMinutesForPeerReplication = 15;

private int minThreadsForPeerReplication = 5;

private int maxThreadsForPeerReplication = 20;

private int maxTimeForReplication = 30000;

private boolean primeAwsReplicaConnections = true;

private boolean disableDeltaForRemoteRegions;

private int remoteRegionConnectTimeoutMs = 1000;

private int remoteRegionReadTimeoutMs = 1000;

private int remoteRegionTotalConnections = 1000;

private int remoteRegionTotalConnectionsPerHost = 500;

private int remoteRegionConnectionIdleTimeoutSeconds = 30;

private boolean gZipContentFromRemoteRegion = true;

private Map<String, String> remoteRegionUrlsWithName = new HashMap<>();

private String[] remoteRegionUrls;

private Map<String, Set<String>> remoteRegionAppWhitelist;

private int remoteRegionRegistryFetchInterval = 30;

private int remoteRegionFetchThreadPoolSize = 20;

private String remoteRegionTrustStore = "";

private String remoteRegionTrustStorePassword = "changeit";

private boolean disableTransparentFallbackToOtherRegion;

private boolean batchReplication;

private boolean rateLimiterEnabled = false;

private boolean rateLimiterThrottleStandardClients = false;

private Set<String> rateLimiterPrivilegedClients = Collections.emptySet();

private int rateLimiterBurstSize = 10;

private int rateLimiterRegistryFetchAverageRate = 500;

private int rateLimiterFullFetchAverageRate = 100;

private boolean logIdentityHeaders = true;

private String listAutoScalingGroupsRoleName = "ListAutoScalingGroups";

private boolean enableReplicatedRequestCompression = false;

private String jsonCodecName;

private String xmlCodecName;

private int route53BindRebindRetries = 3;

private int route53BindingRetryIntervalMs = 5 * MINUTES;

private long route53DomainTTL = 30;

private AwsBindingStrategy bindingStrategy = AwsBindingStrategy.EIP;

private int minAvailableInstancesForPeerReplication = -1;

心得:
1、封装返回类:EurekaHttpResponse参照
2、一个很牛逼的类SmartCycle

本文作者 : braveheart
原文链接 : https://zhangjun075.github.io/passages/springcloud系列-eureka源码解析/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!

知识 & 情怀 | 二者兼得

微信扫一扫, 向我打赏

微信扫一扫, 向我打赏

支付宝扫一扫, 向我打赏

支付宝扫一扫, 向我打赏

留下足迹