当前位置: 首页>>代码示例>>Java>>正文


Java EurekaInstanceConfigBean.setHealthCheckUrl方法代码示例

本文整理汇总了Java中org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.setHealthCheckUrl方法的典型用法代码示例。如果您正苦于以下问题:Java EurekaInstanceConfigBean.setHealthCheckUrl方法的具体用法?Java EurekaInstanceConfigBean.setHealthCheckUrl怎么用?Java EurekaInstanceConfigBean.setHealthCheckUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean的用法示例。


在下文中一共展示了EurekaInstanceConfigBean.setHealthCheckUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eurekaInstanceConfig

import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@Bean
/**
 * Dynamically assign the hosts IP address to this instances of the Eureka Client
 *
 * @param  inetUtils  Java Networks Utilities
 * @return	An instance of a EurekaInstanceConfigBean with dynamically configured IP address
 */
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils){
    EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);

    String ip = null;
    String urlPattern = "http://{0}:{1}{2}";

    try {
        // Get the IP address of the current host using Java Network Utils
        ip = InetAddress.getLocalHost().getHostAddress();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }

    config.setIpAddress(ip);
    config.setPreferIpAddress(true);

    // Build the Status Page URL specific to this instances IP Address
    String statusPageUrl = MessageFormat.format(urlPattern,
            config.getIpAddress(),
            port,
            config.getStatusPageUrlPath());
    config.setStatusPageUrl(statusPageUrl);

    // Build the Health Page URL specific to this instances IP Address
    String healthPageUrl = MessageFormat.format(urlPattern,
            config.getIpAddress(),
            port,
            config.getHealthCheckUrlPath());
    config.setHealthCheckUrl(healthPageUrl);

    return config;
}
 
开发者ID:wb3-spring,项目名称:Trace-Server,代码行数:40,代码来源:WB3TraceServer.java

示例2: eurekaInstanceConfigBean

import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
	EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
	String springAppName = this.env.getProperty("spring.application.name", "");
	int port = this.sidecarProperties.getPort();
	config.setNonSecurePort(port);
	config.setInstanceId(getDefaultInstanceId(this.env));
	if (StringUtils.hasText(springAppName)) {
		config.setAppname(springAppName);
		config.setVirtualHostName(springAppName);
		config.setSecureVirtualHostName(springAppName);
	}
	String hostname = this.sidecarProperties.getHostname();
	String ipAddress = this.sidecarProperties.getIpAddress();
	if (!StringUtils.hasText(hostname) && StringUtils.hasText(this.hostname)) {
		hostname = this.hostname;
	}
	if (StringUtils.hasText(hostname)) {
		config.setHostname(hostname);
	}
	if (StringUtils.hasText(ipAddress)) {
		config.setIpAddress(ipAddress);
	}
	String scheme = config.getSecurePortEnabled() ? "https" : "http";
	config.setStatusPageUrl(scheme + "://" + config.getHostname() + ":"
			+ this.managementPort + config.getStatusPageUrlPath());
	config.setHealthCheckUrl(scheme + "://" + config.getHostname() + ":"
			+ this.managementPort + config.getHealthCheckUrlPath());
	config.setHomePageUrl(scheme + "://" + config.getHostname() + ":" + port
			+ config.getHomePageUrlPath());
	return config;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:33,代码来源:SidecarConfiguration.java


注:本文中的org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.setHealthCheckUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。