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


Java EurekaInstanceConfigBean.setIpAddress方法代码示例

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


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

示例1: setup

import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@Before
public void setup() {
	eurekaHttpClient = new RestTemplateTransportClientFactory()
			.newClient(new DefaultEndpoint(serviceUrl));

	EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);

	String appname = "customapp";
	config.setIpAddress("127.0.0.1");
	config.setHostname("localhost");
	config.setAppname(appname);
	config.setVirtualHostName(appname);
	config.setSecureVirtualHostName(appname);
	config.setNonSecurePort(4444);
	config.setSecurePort(8443);
	config.setInstanceId("127.0.0.1:customapp:4444");

	info = new EurekaConfigBasedInstanceInfoProvider(config).get();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:20,代码来源:RestTemplateEurekaHttpClientTest.java

示例2: register

import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@RequestMapping(path = "/register", method = POST)
public String register() {
	EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
	String appname = "customapp";
	config.setIpAddress("127.0.0.1");
	config.setHostname("localhost");
	config.setAppname(appname);
	config.setVirtualHostName(appname);
	config.setSecureVirtualHostName(appname);
	config.setNonSecurePort(4444);
	config.setInstanceId("127.0.0.1:customapp:4444");

	this.registration = EurekaRegistration.builder(config)
			.with(this.clientConfig, this.context)
			.build();

	this.serviceRegistry.register(this.registration);
	return config.getInstanceId();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:20,代码来源:EurekaSampleApplication.java

示例3: 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

示例4: 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.setIpAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。