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


Java InstanceInfo.getHostName方法代码示例

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


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

示例1: updateIfNeeded

import com.netflix.appinfo.InstanceInfo; //导入方法依赖的package包/类
static InstanceInfo updateIfNeeded(final InstanceInfo info) {
	if (info.getInstanceId() == null && info.getMetadata() != null) {
		String instanceId = info.getMetadata().get("instanceId");
		if (StringUtils.hasText(instanceId)) {
			// backwards compatibility for Angel
			if (StringUtils.hasText(info.getHostName()) && !instanceId.startsWith(info.getHostName())) {
				instanceId = info.getHostName()+":"+instanceId;
			}
			return new InstanceInfo.Builder(info).setInstanceId(instanceId).build();
		}
	}
	return info;
}
 
开发者ID:dyc87112,项目名称:didi-eureka-server,代码行数:14,代码来源:CloudJacksonJson.java

示例2: getRegistration

import com.netflix.appinfo.InstanceInfo; //导入方法依赖的package包/类
protected Registration getRegistration(InstanceInfo instanceInfo) {
	Application application = new Application(instanceInfo.getAppName(), instanceInfo.getInstanceId(), instanceInfo.getHostName(), instanceInfo.getPort());

	Registration registration = new Registration();
	registration.setApplication(application);
	registration.update(instanceInfo);
	return registration;
}
 
开发者ID:spencergibb,项目名称:spring-cloud-netflix-eureka-lite,代码行数:9,代码来源:Eureka.java

示例3: extractId

import com.netflix.appinfo.InstanceInfo; //导入方法依赖的package包/类
private String extractId(Server server) {
	if (server instanceof DiscoveryEnabledServer) {
		DiscoveryEnabledServer enabled = (DiscoveryEnabledServer) server;
		InstanceInfo instance = enabled.getInstanceInfo();
		if (instance.getMetadata().containsKey("instanceId")) {
			return instance.getHostName()+":"+instance.getMetadata().get("instanceId");
		}
	}
	return super.getId();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:11,代码来源:DomainExtractingServerList.java

示例4: marshall

import com.netflix.appinfo.InstanceInfo; //导入方法依赖的package包/类
/**
 * Private helper that marshals the information from each instance into something that
 * Turbine can understand. Override this method for your own implementation for
 * parsing Eureka info.
 * @param instanceInfo
 * @return Instance
 */
Instance marshall(InstanceInfo instanceInfo) {
	String hostname = instanceInfo.getHostName();
	final String managementPort = instanceInfo.getMetadata().get("management.port");
	String port = managementPort == null ? String.valueOf(instanceInfo.getPort()) : managementPort;
	String cluster = getClusterName(instanceInfo);
	Boolean status = parseInstanceStatus(instanceInfo.getStatus());
	if (hostname != null && cluster != null && status != null) {
		Instance instance = getInstance(hostname, port, cluster, status);

		Map<String, String> metadata = instanceInfo.getMetadata();
		boolean securePortEnabled = instanceInfo.isPortEnabled(InstanceInfo.PortType.SECURE);
		String securePort = String.valueOf(instanceInfo.getSecurePort());

		addMetadata(instance, hostname, port, securePortEnabled, securePort, metadata);

		// add amazon metadata
		String asgName = instanceInfo.getASGName();
		if (asgName != null) {
			instance.getAttributes().put(ASG_KEY, asgName);
		}

		DataCenterInfo dcInfo = instanceInfo.getDataCenterInfo();
		if (dcInfo != null && dcInfo.getName().equals(DataCenterInfo.Name.Amazon)) {
			AmazonInfo amznInfo = (AmazonInfo) dcInfo;
			instance.getAttributes().putAll(amznInfo.getMetadata());
		}

		return instance;
	}
	else {
		return null;
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:41,代码来源:EurekaInstanceDiscovery.java


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