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


Java EurekaInstanceConfigBean.setAppname方法代码示例

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


在下文中一共展示了EurekaInstanceConfigBean.setAppname方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getInstanceInfo

import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
public InstanceInfo getInstanceInfo(Application application) {
	EurekaInstanceConfigBean instanceConfig = new EurekaInstanceConfigBean(inetUtils);
	instanceConfig.setInstanceEnabledOnit(true);
	instanceConfig.setAppname(application.getName());
	instanceConfig.setVirtualHostName(application.getName());
	instanceConfig.setInstanceId(application.getInstance_id());
	instanceConfig.setHostname(application.getHostname());
	instanceConfig.setNonSecurePort(application.getPort());

	return new InstanceInfoFactory().create(instanceConfig);
}
 
开发者ID:spencergibb,项目名称:spring-cloud-netflix-eureka-lite,代码行数:12,代码来源:Eureka.java

示例4: eurekaClientGetStatus

import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@Test
public void eurekaClientGetStatus() {
	EurekaServiceRegistry registry = new EurekaServiceRegistry();

	EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
	config.setAppname("myapp");
	config.setInstanceId("1234");

	CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);

	InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
			.setAppName("myapp")
			.setInstanceId("1234")
			.setStatus(DOWN)
			.setOverriddenStatus(UNKNOWN)
			.build();
	when(eurekaClient.getInstanceInfo("myapp", "1234"))
			.thenReturn(instanceInfo);

	EurekaRegistration registration = EurekaRegistration.builder(config)
			.with(eurekaClient)
			.with(mock(ApplicationInfoManager.class))
			.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
			.build();

	Object status = registry.getStatus(registration);

	assertThat(status).isInstanceOf(Map.class);

	Map<Object, Object> map = (Map<Object, Object>) status;

	assertThat(map).hasSize(2)
			.containsEntry("status", DOWN.toString())
			.containsEntry("overriddenStatus", UNKNOWN.toString());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:36,代码来源:EurekaServiceRegistryTests.java

示例5: eurekaClientGetStatusNoInstance

import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; //导入方法依赖的package包/类
@Test
public void eurekaClientGetStatusNoInstance() {
	EurekaServiceRegistry registry = new EurekaServiceRegistry();

	EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
	config.setAppname("myapp");
	config.setInstanceId("1234");

	CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);

	when(eurekaClient.getInstanceInfo("myapp", "1234"))
			.thenReturn(null);

	EurekaRegistration registration = EurekaRegistration.builder(config)
			.with(eurekaClient)
			.with(mock(ApplicationInfoManager.class))
			.with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class))
			.build();

	Object status = registry.getStatus(registration);

	assertThat(status).isInstanceOf(Map.class);

	Map<Object, Object> map = (Map<Object, Object>) status;

	assertThat(map).hasSize(1)
			.containsEntry("status", UNKNOWN.toString());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:29,代码来源:EurekaServiceRegistryTests.java

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