本文整理汇总了Java中com.netflix.appinfo.InstanceInfo.isPortEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java InstanceInfo.isPortEnabled方法的具体用法?Java InstanceInfo.isPortEnabled怎么用?Java InstanceInfo.isPortEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.appinfo.InstanceInfo
的用法示例。
在下文中一共展示了InstanceInfo.isPortEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}