eureka源码系列 - 配置类

eureka源码系列 - 配置类

@Author:zxw
@email:502513206@qq.com
@Jishou University


1.前言

对于我们刚学习eureka入门教程的同学来说,最常做的就是在配置文件上填写eureka相关参数信息,然后配合一个注解就成功启动了eureka服务,所以了解eureka的配置文件相关参数以及默认值也是非常重要的,就让我们一起打开源码看看

2.面试题

最近我在面试一家公司的时候,因为简历上有写springcloud微服务的项目,所以也问了我一些eureka相关面试题,因为是应届生所以总的来说难度挺低。

  1. eureka的尝试重连次数是多少

    // --answer
    
  2. eureka的每隔多少秒会发送一次心跳

    // --answer
    
  3. eureka满足CAP中的哪两个

    // --answer
    

3.源码解析

话不多说,直接告诉你eureka的配置类为EurekaClientConfigBean

该类实现了EurekaClientConfig和Order接口,在EurekaClientConfig接口中定义了一些获取字段值以及区域等其他方法。可以看到该类被@ConfigurationProperties注解修饰,如果我们有需要自定义yml配置的,也可以使用该注解修饰。

  1. 所使用的前缀为eureka.client,该值定义在PREFIX字段中
  2. 默认地址为:http://localhost:8761/eureka/
  3. 默认zone:defaultZone
  4. 从注册中心拉取其他服务注册信息间隔时间:30s
  5. 复制实例变化信息到eureka服务器所需要的时间间隔 :30s
  6. 最初复制实例信息到eureka服务器所需的时间 :40s
  7. 询问Eureka服务url信息变化的时间间隔 :5 * 60
package org.springframework.cloud.netflix.eureka;

/**
 * Eureka client configuration bean.
 *
 * @author Dave Syer
 * @author Gregor Zurowski
 */
@ConfigurationProperties(EurekaClientConfigBean.PREFIX)
public class EurekaClientConfigBean implements EurekaClientConfig, Ordered {

	/**
	 * yml中的前缀
	 */
	public static final String PREFIX = "eureka.client";

	/**
	 * eureka默认地址
	 */
	public static final String DEFAULT_URL = "http://localhost:8761" + DEFAULT_PREFIX
			+ "/";

	/**
	 * 默认zone 
	 */
	public static final String DEFAULT_ZONE = "defaultZone";

	private static final int MINUTES = 60;

	@Autowired(required = false)
	PropertyResolver propertyResolver;

	/**
	 * 标志eureka是否可用
	 */
	private boolean enabled = true;

    /**
	 * 传输配置
	 */
	@NestedConfigurationProperty
	private EurekaTransportConfig transport = new CloudEurekaTransportConfig();

	/**
	 *  从注册中心拉取服务注册信息间隔时间
	 */
	private int registryFetchIntervalSeconds = 30;

	/**
	 * 将实例复制到注册中心的间隔时间
	 */
	private int instanceInfoReplicationIntervalSeconds = 30;

	/**
	 * 最初复制实例信息到eureka服务器所需的时间
	 */
	private int initialInstanceInfoReplicationIntervalSeconds = 40;

	/**
	 * 询问Eureka服务url信息变化的时间间隔
	 */
	private int eurekaServiceUrlPollIntervalSeconds = 5 * MINUTES;

	/**
	 * eureka服务的代理端口
	 */
	private String proxyPort;

	/**
	 * eureka服务的代理主机
	 */
	private String proxyHost;

	/**
	 * 代理用户名
	 */
	private String proxyUserName;

	/**
	 * 代理用户名
	 */
	private String proxyPassword;

	/**
	 * eureka需要超时读取之前需要等待的时间
	 */
	private int eurekaServerReadTimeoutSeconds = 8;

	/**
	 *  eureka需要超时连接之前需要等待的时间
	 */
	private int eurekaServerConnectTimeoutSeconds = 5;

	/**
	 * 获取实现了eureka客户端在第一次启动时读取注册表的信息作为回退选项的实现名称
	 */
	private String backupRegistryImpl;

	/**
	 * eureka客户端允许所有eureka服务器连接的总数目,默认是200
	 */
	private int eurekaServerTotalConnections = 200;

	/**
	 * eureka客户端允许eureka服务器主机连接的总数目,默认是50
	 */
	private int eurekaServerTotalConnectionsPerHost = 50;

	/**
	 * 表示eureka注册中心的路径,如果配置为eureka,则为http://x.x.x.x:x/eureka/,在eureka的配置文件中加入此配置表示eureka作为客户端向注册中心注册,从而构成eureka集群。此配置只有在eureka服务器ip地址列表是在DNS中才会用到,默认为null
	 */
	private String eurekaServerURLContext;

	/**
	 * 获取eureka服务器的端口,此配置只有在eureka服务器ip地址列表是在DNS中才  	 * 会用到。默认为null
	 */
	private String eurekaServerPort;

	/**
	 * 获取要查询的DNS名称来获得eureka服务器,此配置只有在eureka服务器ip地  	 	* 址列表是在DNS中才会用到。默认为null
	 */
	private String eurekaServerDNSName;

	/**
	 * 默认所在region
	 */
	private String region = "us-east-1";

	/**
	 * Eureka服务的http请求关闭之前其响应的时间,默认为30 秒
	 */
	private int eurekaConnectionIdleTimeoutSeconds = 30;

	/**
	 * 此客户端只对一个单一的VIP注册表的信息感兴趣。默认为null
	 */
	private String registryRefreshSingleVipAddress;

	/**
	 * 心跳执行程序线程池的大小,默认为2
	 */
	private int heartbeatExecutorThreadPoolSize = 2;

	/**
	 * 心跳执行程序回退相关的属性,是重试延迟的最大倍数值,默认为10
	 */
	private int heartbeatExecutorExponentialBackOffBound = 10;

	/**
	 * 执行程序缓存刷新线程池的大小,默认为2
	 */
	private int cacheRefreshExecutorThreadPoolSize = 2;

	/**
	 * 执行程序指数回退刷新的相关属性,是重试延迟的最大倍数值,默认为10
	 */
	private int cacheRefreshExecutorExponentialBackOffBound = 10;

	/**
	 * Map of availability zone to list of fully qualified URLs to communicate with eureka
	 * server. Each value can be a single URL or a comma separated list of alternative
	 * locations.
	 *
	 * Typically the eureka server URLs carry protocol,host,port,context and version
	 * information if any. Example:
	 * https://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/
	 *
	 * The changes are effective at runtime at the next service url refresh cycle as
	 * specified by eurekaServiceUrlPollIntervalSeconds.
	 */
	private Map<String, String> serviceUrl = new HashMap<>();

	{
		this.serviceUrl.put(DEFAULT_ZONE, DEFAULT_URL);
	}

	/**
	 * Indicates whether the content fetched from eureka server has to be compressed
	 * whenever it is supported by the server. The registry information from the eureka
	 * server is compressed for optimum network traffic.
	 */
	private boolean gZipContent = true;

	/**
	 * Indicates whether the eureka client should use the DNS mechanism to fetch a list of
	 * eureka servers to talk to. When the DNS name is updated to have additional servers,
	 * that information is used immediately after the eureka client polls for that
	 * information as specified in eurekaServiceUrlPollIntervalSeconds.
	 *
	 * Alternatively, the service urls can be returned serviceUrls, but the users should
	 * implement their own mechanism to return the updated list in case of changes.
	 *
	 * The changes are effective at runtime.
	 */
	private boolean useDnsForFetchingServiceUrls = false;

	/**
	 * 实例是否在eureka服务器上注册自己的信息以供其他服务发现,默认为true
	 */
	private boolean registerWithEureka = true;

	/**
	 * 实例是否使用同一zone里的eureka服务器,默认为true,理想状态下,eureka		* 客户端与服务端是在同一zone下
	 */
	private boolean preferSameZoneEureka = true;

	/**
	 *是否记录eureka服务器和客户端之间在注册表的信息方面的差异,默认为false
	 */
	private boolean logDeltaDiff;

	/**
	 * Indicates whether the eureka client should disable fetching of delta and should
	 * rather resort to getting the full registry information.
	 *
	 * Note that the delta fetches can reduce the traffic tremendously, because the rate
	 * of change with the eureka server is normally much lower than the rate of fetches.
	 *
	 * The changes are effective at runtime at the next registry fetch cycle as specified
	 * by registryFetchIntervalSeconds
	 */
	private boolean disableDelta;

	/**
	 * eureka服务注册表信息里的以逗号隔开的地区名单,如果不这样返回这些地区名	  * 单,则客户端启动将会出错。默认为null
	 *
	 */
	private String fetchRemoteRegionsRegistry;

	/**
	 * 获取实例所在的地区下可用性的区域列表,用逗号隔开。
	 */
	private Map<String, String> availabilityZones = new HashMap<>();

	/**
	 * Indicates whether to get the applications after filtering the applications for
	 * instances with only InstanceStatus UP states.
	 */
	private boolean filterOnlyUpInstances = true;

	/**
	 * 此客户端是否获取eureka服务器注册表上的注册信息,默认为true
	 */
	private boolean fetchRegistry = true;

	/**
	 * Get a replacement string for Dollar sign <code>$</code> during
	 * serializing/deserializing information in eureka server.
	 */
	private String dollarReplacement = "_-";

	/**
	 * Get a replacement string for underscore sign <code>_</code> during serializing/
	 * deserializing information in eureka server.
	 */
	private String escapeCharReplacement = "__";

	/**
	 * Indicates whether server can redirect a client request to a backup server/cluster.
	 * If set to false, the server will handle the request directly, If set to true, it
	 * may send HTTP redirect to the client, with a new server location.
	 */
	private boolean allowRedirects = false;

	/**
	 * If set to true, local status updates via ApplicationInfoManager will trigger
	 * on-demand (but rate limited) register/updates to remote eureka servers.
	 */
	private boolean onDemandUpdateStatusChange = true;

	/**
	 * This is a transient config and once the latest codecs are stable, can be removed
	 * (as there will only be one).
	 */
	private String encoderName;

	/**
	 * This is a transient config and once the latest codecs are stable, can be removed
	 * (as there will only be one).
	 */
	private String decoderName;

	/**
	 * EurekaAccept name for client data accept.
	 */
	private String clientDataAccept = EurekaAccept.full.name();

	/**
	 * Indicates whether the client should explicitly unregister itself from the remote
	 * server on client shutdown.
	 */
	private boolean shouldUnregisterOnShutdown = true;

	/**
	 * Indicates whether the client should enforce registration during initialization.
	 * Defaults to false.
	 */
	private boolean shouldEnforceRegistrationAtInit = false;

	/**
	 * Order of the discovery client used by `CompositeDiscoveryClient` for sorting
	 * available clients.
	 */
	private int order = 0;

	@Override
	public boolean shouldGZipContent() {
		return this.gZipContent;
	}

	@Override
	public boolean shouldUseDnsForFetchingServiceUrls() {
		return this.useDnsForFetchingServiceUrls;
	}

	@Override
	public boolean shouldRegisterWithEureka() {
		return this.registerWithEureka;
	}

	@Override
	public boolean shouldPreferSameZoneEureka() {
		return this.preferSameZoneEureka;
	}

	@Override
	public boolean shouldLogDeltaDiff() {
		return this.logDeltaDiff;
	}

	@Override
	public boolean shouldDisableDelta() {
		return this.disableDelta;
	}

	@Override
	public boolean shouldUnregisterOnShutdown() {
		return this.shouldUnregisterOnShutdown;
	}

	@Override
	public boolean shouldEnforceRegistrationAtInit() {
		return this.shouldEnforceRegistrationAtInit;
	}

	@Override
	public String fetchRegistryForRemoteRegions() {
		return this.fetchRemoteRegionsRegistry;
	}

	@Override
	public String[] getAvailabilityZones(String region) {
		String value = this.availabilityZones.get(region);
		if (value == null) {
			value = DEFAULT_ZONE;
		}
		return value.split(",");
	}

	@Override
	public List<String> getEurekaServerServiceUrls(String myZone) {
		String serviceUrls = this.serviceUrl.get(myZone);
		if (serviceUrls == null || serviceUrls.isEmpty()) {
			serviceUrls = this.serviceUrl.get(DEFAULT_ZONE);
		}
		if (!StringUtils.isEmpty(serviceUrls)) {
			final String[] serviceUrlsSplit = StringUtils
					.commaDelimitedListToStringArray(serviceUrls);
			List<String> eurekaServiceUrls = new ArrayList<>(serviceUrlsSplit.length);
			for (String eurekaServiceUrl : serviceUrlsSplit) {
				if (!endsWithSlash(eurekaServiceUrl)) {
					eurekaServiceUrl += "/";
				}
				eurekaServiceUrls.add(eurekaServiceUrl.trim());
			}
			return eurekaServiceUrls;
		}

		return new ArrayList<>();
	}

	private boolean endsWithSlash(String url) {
		return url.endsWith("/");
	}

	@Override
	public boolean shouldFilterOnlyUpInstances() {
		return this.filterOnlyUpInstances;
	}

	@Override
	public boolean shouldFetchRegistry() {
		return this.fetchRegistry;
	}

	@Override
	public boolean allowRedirects() {
		return this.allowRedirects;
	}

	@Override
	public boolean shouldOnDemandUpdateStatusChange() {
		return this.onDemandUpdateStatusChange;
	}

	@Override
	public String getExperimental(String name) {
		if (this.propertyResolver != null) {
			return this.propertyResolver.getProperty(PREFIX + ".experimental." + name,
					String.class, null);
		}
		return null;
	}

	@Override
	public EurekaTransportConfig getTransportConfig() {
		return getTransport();
	}

	public PropertyResolver getPropertyResolver() {
		return propertyResolver;
	}

	public void setPropertyResolver(PropertyResolver propertyResolver) {
		this.propertyResolver = propertyResolver;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public EurekaTransportConfig getTransport() {
		return transport;
	}

	public void setTransport(EurekaTransportConfig transport) {
		this.transport = transport;
	}

	@Override
	public int getRegistryFetchIntervalSeconds() {
		return registryFetchIntervalSeconds;
	}

	public void setRegistryFetchIntervalSeconds(int registryFetchIntervalSeconds) {
		this.registryFetchIntervalSeconds = registryFetchIntervalSeconds;
	}

	@Override
	public int getInstanceInfoReplicationIntervalSeconds() {
		return instanceInfoReplicationIntervalSeconds;
	}

	public void setInstanceInfoReplicationIntervalSeconds(
			int instanceInfoReplicationIntervalSeconds) {
		this.instanceInfoReplicationIntervalSeconds = instanceInfoReplicationIntervalSeconds;
	}

	@Override
	public int getInitialInstanceInfoReplicationIntervalSeconds() {
		return initialInstanceInfoReplicationIntervalSeconds;
	}

	public void setInitialInstanceInfoReplicationIntervalSeconds(
			int initialInstanceInfoReplicationIntervalSeconds) {
		this.initialInstanceInfoReplicationIntervalSeconds = initialInstanceInfoReplicationIntervalSeconds;
	}

	@Override
	public int getEurekaServiceUrlPollIntervalSeconds() {
		return eurekaServiceUrlPollIntervalSeconds;
	}

	public void setEurekaServiceUrlPollIntervalSeconds(
			int eurekaServiceUrlPollIntervalSeconds) {
		this.eurekaServiceUrlPollIntervalSeconds = eurekaServiceUrlPollIntervalSeconds;
	}

	@Override
	public String getProxyPort() {
		return proxyPort;
	}

	public void setProxyPort(String proxyPort) {
		this.proxyPort = proxyPort;
	}

	@Override
	public String getProxyHost() {
		return proxyHost;
	}

	public void setProxyHost(String proxyHost) {
		this.proxyHost = proxyHost;
	}

	@Override
	public String getProxyUserName() {
		return proxyUserName;
	}

	public void setProxyUserName(String proxyUserName) {
		this.proxyUserName = proxyUserName;
	}

	@Override
	public String getProxyPassword() {
		return proxyPassword;
	}

	public void setProxyPassword(String proxyPassword) {
		this.proxyPassword = proxyPassword;
	}

	@Override
	public int getEurekaServerReadTimeoutSeconds() {
		return eurekaServerReadTimeoutSeconds;
	}

	public void setEurekaServerReadTimeoutSeconds(int eurekaServerReadTimeoutSeconds) {
		this.eurekaServerReadTimeoutSeconds = eurekaServerReadTimeoutSeconds;
	}

	@Override
	public int getEurekaServerConnectTimeoutSeconds() {
		return eurekaServerConnectTimeoutSeconds;
	}

	public void setEurekaServerConnectTimeoutSeconds(
			int eurekaServerConnectTimeoutSeconds) {
		this.eurekaServerConnectTimeoutSeconds = eurekaServerConnectTimeoutSeconds;
	}

	@Override
	public String getBackupRegistryImpl() {
		return backupRegistryImpl;
	}

	public void setBackupRegistryImpl(String backupRegistryImpl) {
		this.backupRegistryImpl = backupRegistryImpl;
	}

	@Override
	public int getEurekaServerTotalConnections() {
		return eurekaServerTotalConnections;
	}

	public void setEurekaServerTotalConnections(int eurekaServerTotalConnections) {
		this.eurekaServerTotalConnections = eurekaServerTotalConnections;
	}

	@Override
	public int getEurekaServerTotalConnectionsPerHost() {
		return eurekaServerTotalConnectionsPerHost;
	}

	public void setEurekaServerTotalConnectionsPerHost(
			int eurekaServerTotalConnectionsPerHost) {
		this.eurekaServerTotalConnectionsPerHost = eurekaServerTotalConnectionsPerHost;
	}

	@Override
	public String getEurekaServerURLContext() {
		return eurekaServerURLContext;
	}

	public void setEurekaServerURLContext(String eurekaServerURLContext) {
		this.eurekaServerURLContext = eurekaServerURLContext;
	}

	@Override
	public String getEurekaServerPort() {
		return eurekaServerPort;
	}

	public void setEurekaServerPort(String eurekaServerPort) {
		this.eurekaServerPort = eurekaServerPort;
	}

	@Override
	public String getEurekaServerDNSName() {
		return eurekaServerDNSName;
	}

	public void setEurekaServerDNSName(String eurekaServerDNSName) {
		this.eurekaServerDNSName = eurekaServerDNSName;
	}

	@Override
	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	@Override
	public int getEurekaConnectionIdleTimeoutSeconds() {
		return eurekaConnectionIdleTimeoutSeconds;
	}

	public void setEurekaConnectionIdleTimeoutSeconds(
			int eurekaConnectionIdleTimeoutSeconds) {
		this.eurekaConnectionIdleTimeoutSeconds = eurekaConnectionIdleTimeoutSeconds;
	}

	@Override
	public String getRegistryRefreshSingleVipAddress() {
		return registryRefreshSingleVipAddress;
	}

	public void setRegistryRefreshSingleVipAddress(
			String registryRefreshSingleVipAddress) {
		this.registryRefreshSingleVipAddress = registryRefreshSingleVipAddress;
	}

	@Override
	public int getHeartbeatExecutorThreadPoolSize() {
		return heartbeatExecutorThreadPoolSize;
	}

	public void setHeartbeatExecutorThreadPoolSize(int heartbeatExecutorThreadPoolSize) {
		this.heartbeatExecutorThreadPoolSize = heartbeatExecutorThreadPoolSize;
	}

	@Override
	public int getHeartbeatExecutorExponentialBackOffBound() {
		return heartbeatExecutorExponentialBackOffBound;
	}

	public void setHeartbeatExecutorExponentialBackOffBound(
			int heartbeatExecutorExponentialBackOffBound) {
		this.heartbeatExecutorExponentialBackOffBound = heartbeatExecutorExponentialBackOffBound;
	}

	@Override
	public int getCacheRefreshExecutorThreadPoolSize() {
		return cacheRefreshExecutorThreadPoolSize;
	}

	public void setCacheRefreshExecutorThreadPoolSize(
			int cacheRefreshExecutorThreadPoolSize) {
		this.cacheRefreshExecutorThreadPoolSize = cacheRefreshExecutorThreadPoolSize;
	}

	@Override
	public int getCacheRefreshExecutorExponentialBackOffBound() {
		return cacheRefreshExecutorExponentialBackOffBound;
	}

	public void setCacheRefreshExecutorExponentialBackOffBound(
			int cacheRefreshExecutorExponentialBackOffBound) {
		this.cacheRefreshExecutorExponentialBackOffBound = cacheRefreshExecutorExponentialBackOffBound;
	}

	public Map<String, String> getServiceUrl() {
		return serviceUrl;
	}

	public void setServiceUrl(Map<String, String> serviceUrl) {
		this.serviceUrl = serviceUrl;
	}

	public boolean isgZipContent() {
		return gZipContent;
	}

	public void setgZipContent(boolean gZipContent) {
		this.gZipContent = gZipContent;
	}

	public boolean isUseDnsForFetchingServiceUrls() {
		return useDnsForFetchingServiceUrls;
	}

	public void setUseDnsForFetchingServiceUrls(boolean useDnsForFetchingServiceUrls) {
		this.useDnsForFetchingServiceUrls = useDnsForFetchingServiceUrls;
	}

	public boolean isRegisterWithEureka() {
		return registerWithEureka;
	}

	public void setRegisterWithEureka(boolean registerWithEureka) {
		this.registerWithEureka = registerWithEureka;
	}

	public boolean isPreferSameZoneEureka() {
		return preferSameZoneEureka;
	}

	public void setPreferSameZoneEureka(boolean preferSameZoneEureka) {
		this.preferSameZoneEureka = preferSameZoneEureka;
	}

	public boolean isLogDeltaDiff() {
		return logDeltaDiff;
	}

	public void setLogDeltaDiff(boolean logDeltaDiff) {
		this.logDeltaDiff = logDeltaDiff;
	}

	public boolean isDisableDelta() {
		return disableDelta;
	}

	public void setDisableDelta(boolean disableDelta) {
		this.disableDelta = disableDelta;
	}

	public String getFetchRemoteRegionsRegistry() {
		return fetchRemoteRegionsRegistry;
	}

	public void setFetchRemoteRegionsRegistry(String fetchRemoteRegionsRegistry) {
		this.fetchRemoteRegionsRegistry = fetchRemoteRegionsRegistry;
	}

	public Map<String, String> getAvailabilityZones() {
		return availabilityZones;
	}

	public void setAvailabilityZones(Map<String, String> availabilityZones) {
		this.availabilityZones = availabilityZones;
	}

	public boolean isFilterOnlyUpInstances() {
		return filterOnlyUpInstances;
	}

	public void setFilterOnlyUpInstances(boolean filterOnlyUpInstances) {
		this.filterOnlyUpInstances = filterOnlyUpInstances;
	}

	public boolean isFetchRegistry() {
		return fetchRegistry;
	}

	public void setFetchRegistry(boolean fetchRegistry) {
		this.fetchRegistry = fetchRegistry;
	}

	@Override
	public String getDollarReplacement() {
		return dollarReplacement;
	}

	public void setDollarReplacement(String dollarReplacement) {
		this.dollarReplacement = dollarReplacement;
	}

	@Override
	public String getEscapeCharReplacement() {
		return escapeCharReplacement;
	}

	public void setEscapeCharReplacement(String escapeCharReplacement) {
		this.escapeCharReplacement = escapeCharReplacement;
	}

	public boolean isAllowRedirects() {
		return allowRedirects;
	}

	public void setAllowRedirects(boolean allowRedirects) {
		this.allowRedirects = allowRedirects;
	}

	public boolean isOnDemandUpdateStatusChange() {
		return onDemandUpdateStatusChange;
	}

	public void setOnDemandUpdateStatusChange(boolean onDemandUpdateStatusChange) {
		this.onDemandUpdateStatusChange = onDemandUpdateStatusChange;
	}

	@Override
	public String getEncoderName() {
		return encoderName;
	}

	public void setEncoderName(String encoderName) {
		this.encoderName = encoderName;
	}

	@Override
	public String getDecoderName() {
		return decoderName;
	}

	public void setDecoderName(String decoderName) {
		this.decoderName = decoderName;
	}

	@Override
	public String getClientDataAccept() {
		return clientDataAccept;
	}

	public void setClientDataAccept(String clientDataAccept) {
		this.clientDataAccept = clientDataAccept;
	}

	public boolean isShouldUnregisterOnShutdown() {
		return shouldUnregisterOnShutdown;
	}

	public void setShouldUnregisterOnShutdown(boolean shouldUnregisterOnShutdown) {
		this.shouldUnregisterOnShutdown = shouldUnregisterOnShutdown;
	}

	public boolean isShouldEnforceRegistrationAtInit() {
		return shouldEnforceRegistrationAtInit;
	}

	public void setShouldEnforceRegistrationAtInit(
			boolean shouldEnforceRegistrationAtInit) {
		this.shouldEnforceRegistrationAtInit = shouldEnforceRegistrationAtInit;
	}

	@Override
	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		EurekaClientConfigBean that = (EurekaClientConfigBean) o;
		return Objects.equals(propertyResolver, that.propertyResolver)
				&& enabled == that.enabled && Objects.equals(transport, that.transport)
				&& registryFetchIntervalSeconds == that.registryFetchIntervalSeconds
				&& instanceInfoReplicationIntervalSeconds == that.instanceInfoReplicationIntervalSeconds
				&& initialInstanceInfoReplicationIntervalSeconds == that.initialInstanceInfoReplicationIntervalSeconds
				&& eurekaServiceUrlPollIntervalSeconds == that.eurekaServiceUrlPollIntervalSeconds
				&& eurekaServerReadTimeoutSeconds == that.eurekaServerReadTimeoutSeconds
				&& eurekaServerConnectTimeoutSeconds == that.eurekaServerConnectTimeoutSeconds
				&& eurekaServerTotalConnections == that.eurekaServerTotalConnections
				&& eurekaServerTotalConnectionsPerHost == that.eurekaServerTotalConnectionsPerHost
				&& eurekaConnectionIdleTimeoutSeconds == that.eurekaConnectionIdleTimeoutSeconds
				&& heartbeatExecutorThreadPoolSize == that.heartbeatExecutorThreadPoolSize
				&& heartbeatExecutorExponentialBackOffBound == that.heartbeatExecutorExponentialBackOffBound
				&& cacheRefreshExecutorThreadPoolSize == that.cacheRefreshExecutorThreadPoolSize
				&& cacheRefreshExecutorExponentialBackOffBound == that.cacheRefreshExecutorExponentialBackOffBound
				&& gZipContent == that.gZipContent
				&& useDnsForFetchingServiceUrls == that.useDnsForFetchingServiceUrls
				&& registerWithEureka == that.registerWithEureka
				&& preferSameZoneEureka == that.preferSameZoneEureka
				&& logDeltaDiff == that.logDeltaDiff && disableDelta == that.disableDelta
				&& filterOnlyUpInstances == that.filterOnlyUpInstances
				&& fetchRegistry == that.fetchRegistry
				&& allowRedirects == that.allowRedirects
				&& onDemandUpdateStatusChange == that.onDemandUpdateStatusChange
				&& shouldUnregisterOnShutdown == that.shouldUnregisterOnShutdown
				&& shouldEnforceRegistrationAtInit == that.shouldEnforceRegistrationAtInit
				&& Objects.equals(proxyPort, that.proxyPort)
				&& Objects.equals(proxyHost, that.proxyHost)
				&& Objects.equals(proxyUserName, that.proxyUserName)
				&& Objects.equals(proxyPassword, that.proxyPassword)
				&& Objects.equals(backupRegistryImpl, that.backupRegistryImpl)
				&& Objects.equals(eurekaServerURLContext, that.eurekaServerURLContext)
				&& Objects.equals(eurekaServerPort, that.eurekaServerPort)
				&& Objects.equals(eurekaServerDNSName, that.eurekaServerDNSName)
				&& Objects.equals(region, that.region)
				&& Objects.equals(registryRefreshSingleVipAddress,
						that.registryRefreshSingleVipAddress)
				&& Objects.equals(serviceUrl, that.serviceUrl)
				&& Objects.equals(fetchRemoteRegionsRegistry,
						that.fetchRemoteRegionsRegistry)
				&& Objects.equals(availabilityZones, that.availabilityZones)
				&& Objects.equals(dollarReplacement, that.dollarReplacement)
				&& Objects.equals(escapeCharReplacement, that.escapeCharReplacement)
				&& Objects.equals(encoderName, that.encoderName)
				&& Objects.equals(decoderName, that.decoderName)
				&& Objects.equals(clientDataAccept, that.clientDataAccept)
				&& Objects.equals(order, that.order);
	}

	@Override
	public int hashCode() {
		return Objects.hash(propertyResolver, enabled, transport,
				registryFetchIntervalSeconds, instanceInfoReplicationIntervalSeconds,
				initialInstanceInfoReplicationIntervalSeconds,
				eurekaServiceUrlPollIntervalSeconds, proxyPort, proxyHost, proxyUserName,
				proxyPassword, eurekaServerReadTimeoutSeconds,
				eurekaServerConnectTimeoutSeconds, backupRegistryImpl,
				eurekaServerTotalConnections, eurekaServerTotalConnectionsPerHost,
				eurekaServerURLContext, eurekaServerPort, eurekaServerDNSName, region,
				eurekaConnectionIdleTimeoutSeconds, registryRefreshSingleVipAddress,
				heartbeatExecutorThreadPoolSize, heartbeatExecutorExponentialBackOffBound,
				cacheRefreshExecutorThreadPoolSize,
				cacheRefreshExecutorExponentialBackOffBound, serviceUrl, gZipContent,
				useDnsForFetchingServiceUrls, registerWithEureka, preferSameZoneEureka,
				logDeltaDiff, disableDelta, fetchRemoteRegionsRegistry, availabilityZones,
				filterOnlyUpInstances, fetchRegistry, dollarReplacement,
				escapeCharReplacement, allowRedirects, onDemandUpdateStatusChange,
				encoderName, decoderName, clientDataAccept, shouldUnregisterOnShutdown,
				shouldEnforceRegistrationAtInit, order);
	}

	@Override
	public String toString() {
		return new StringBuilder("EurekaClientConfigBean{").append("propertyResolver=")
				.append(propertyResolver).append(", ").append("enabled=").append(enabled)
				.append(", ").append("transport=").append(transport).append(", ")
				.append("registryFetchIntervalSeconds=")
				.append(registryFetchIntervalSeconds).append(", ")
				.append("instanceInfoReplicationIntervalSeconds=")
				.append(instanceInfoReplicationIntervalSeconds).append(", ")
				.append("initialInstanceInfoReplicationIntervalSeconds=")
				.append(initialInstanceInfoReplicationIntervalSeconds).append(", ")
				.append("eurekaServiceUrlPollIntervalSeconds=")
				.append(eurekaServiceUrlPollIntervalSeconds).append(", ")
				.append("proxyPort='").append(proxyPort).append("', ")
				.append("proxyHost='").append(proxyHost).append("', ")
				.append("proxyUserName='").append(proxyUserName).append("', ")
				.append("proxyPassword='").append(proxyPassword).append("', ")
				.append("eurekaServerReadTimeoutSeconds=")
				.append(eurekaServerReadTimeoutSeconds).append(", ")
				.append("eurekaServerConnectTimeoutSeconds=")
				.append(eurekaServerConnectTimeoutSeconds).append(", ")
				.append("backupRegistryImpl='").append(backupRegistryImpl).append("', ")
				.append("eurekaServerTotalConnections=")
				.append(eurekaServerTotalConnections).append(", ")
				.append("eurekaServerTotalConnectionsPerHost=")
				.append(eurekaServerTotalConnectionsPerHost).append(", ")
				.append("eurekaServerURLContext='").append(eurekaServerURLContext)
				.append("', ").append("eurekaServerPort='").append(eurekaServerPort)
				.append("', ").append("eurekaServerDNSName='").append(eurekaServerDNSName)
				.append("', ").append("region='").append(region).append("', ")
				.append("eurekaConnectionIdleTimeoutSeconds=")
				.append(eurekaConnectionIdleTimeoutSeconds).append(", ")
				.append("registryRefreshSingleVipAddress='")
				.append(registryRefreshSingleVipAddress).append("', ")
				.append("heartbeatExecutorThreadPoolSize=")
				.append(heartbeatExecutorThreadPoolSize).append(", ")
				.append("heartbeatExecutorExponentialBackOffBound=")
				.append(heartbeatExecutorExponentialBackOffBound).append(", ")
				.append("cacheRefreshExecutorThreadPoolSize=")
				.append(cacheRefreshExecutorThreadPoolSize).append(", ")
				.append("cacheRefreshExecutorExponentialBackOffBound=")
				.append(cacheRefreshExecutorExponentialBackOffBound).append(", ")
				.append("serviceUrl=").append(serviceUrl).append(", ")
				.append("gZipContent=").append(gZipContent).append(", ")
				.append("useDnsForFetchingServiceUrls=")
				.append(useDnsForFetchingServiceUrls).append(", ")
				.append("registerWithEureka=").append(registerWithEureka).append(", ")
				.append("preferSameZoneEureka=").append(preferSameZoneEureka).append(", ")
				.append("logDeltaDiff=").append(logDeltaDiff).append(", ")
				.append("disableDelta=").append(disableDelta).append(", ")
				.append("fetchRemoteRegionsRegistry='").append(fetchRemoteRegionsRegistry)
				.append("', ").append("availabilityZones=").append(availabilityZones)
				.append(", ").append("filterOnlyUpInstances=")
				.append(filterOnlyUpInstances).append(", ").append("fetchRegistry=")
				.append(fetchRegistry).append(", ").append("dollarReplacement='")
				.append(dollarReplacement).append("', ").append("escapeCharReplacement='")
				.append(escapeCharReplacement).append("', ").append("allowRedirects=")
				.append(allowRedirects).append(", ").append("onDemandUpdateStatusChange=")
				.append(onDemandUpdateStatusChange).append(", ").append("encoderName='")
				.append(encoderName).append("', ").append("decoderName='")
				.append(decoderName).append("', ").append("clientDataAccept='")
				.append(clientDataAccept).append("', ")
				.append("shouldUnregisterOnShutdown='").append(shouldUnregisterOnShutdown)
				.append("', ").append("shouldEnforceRegistrationAtInit='")
				.append(shouldEnforceRegistrationAtInit).append("', ").append("order='")
				.append(order).append("'}").toString();
	}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值