use of com.alibaba.nacos.naming.pojo.IpAddressInfo in project nacos by alibaba.
the class CatalogServiceV2Impl method transferToIpAddressInfo.
private IpAddressInfo transferToIpAddressInfo(Instance instance) {
IpAddressInfo result = new IpAddressInfo();
result.setIp(instance.getIp());
result.setPort(instance.getPort());
result.setEnabled(instance.isEnabled());
result.setValid(instance.isHealthy());
result.setWeight(instance.getWeight());
result.setMetadata(instance.getMetadata());
return result;
}
use of com.alibaba.nacos.naming.pojo.IpAddressInfo in project nacos by alibaba.
the class CatalogServiceV2Impl method getClusterMap.
private Map<String, ClusterInfo> getClusterMap(Service service) {
Map<String, ClusterInfo> result = new HashMap<>(1);
for (Instance each : serviceStorage.getData(service).getHosts()) {
final IpAddressInfo info = transferToIpAddressInfo(each);
if (!result.containsKey(each.getClusterName())) {
ClusterInfo clusterInfo = new ClusterInfo();
clusterInfo.setHosts(new LinkedList<>());
result.put(each.getClusterName(), clusterInfo);
}
result.get(each.getClusterName()).getHosts().add(info);
}
return result;
}
use of com.alibaba.nacos.naming.pojo.IpAddressInfo in project nacos by alibaba.
the class CatalogServiceV1Impl method getStringClusterInfoMap.
private Map<String, ClusterInfo> getStringClusterInfoMap(Service service) {
Map<String, ClusterInfo> clusterInfoMap = new HashMap<>(8);
service.getClusterMap().forEach((clusterName, cluster) -> {
ClusterInfo clusterInfo = new ClusterInfo();
List<IpAddressInfo> ipAddressInfos = getIpAddressInfos(cluster.allIPs());
clusterInfo.setHosts(ipAddressInfos);
clusterInfoMap.put(clusterName, clusterInfo);
});
return clusterInfoMap;
}
use of com.alibaba.nacos.naming.pojo.IpAddressInfo in project nacos by alibaba.
the class CatalogServiceV1Impl method getIpAddressInfos.
private List<IpAddressInfo> getIpAddressInfos(List<com.alibaba.nacos.naming.core.Instance> instances) {
List<IpAddressInfo> ipAddressInfos = new ArrayList<>();
instances.forEach((ipAddress) -> {
IpAddressInfo ipAddressInfo = new IpAddressInfo();
ipAddressInfo.setIp(ipAddress.getIp());
ipAddressInfo.setPort(ipAddress.getPort());
ipAddressInfo.setMetadata(ipAddress.getMetadata());
ipAddressInfo.setValid(ipAddress.isHealthy());
ipAddressInfo.setWeight(ipAddress.getWeight());
ipAddressInfo.setEnabled(ipAddress.isEnabled());
ipAddressInfos.add(ipAddressInfo);
});
return ipAddressInfos;
}
Aggregations