use of org.platformlayer.InetAddressChooser in project platformlayer by platformlayer.
the class StandardTemplateData method getConfigurationProperties.
protected Map<String, String> getConfigurationProperties() throws OpsException {
Map<String, String> properties = Maps.newHashMap();
List<Link> modelLinks = getLinks();
if (modelLinks != null && !modelLinks.isEmpty()) {
NetworkPoint networkPoint = NetworkPoint.forTargetInContext();
InetAddressChooser inetAddressChooser = NearestAddressChooser.build(networkPoint);
SimpleLinkConsumer consumer = new SimpleLinkConsumer(getModel().getKey(), inetAddressChooser);
properties.putAll(links.buildLinkTargetProperties(consumer, modelLinks));
}
return properties;
}
use of org.platformlayer.InetAddressChooser in project platformlayer by platformlayer.
the class HttpBackends method buildUri.
public URI buildUri(NetworkPoint src, String scheme, ItemBase model, int port) throws OpsException {
Machine machine = instances.getMachine(model);
InetAddressChooser chooser = InetAddressChooser.preferIpv6();
InetAddress address = machine.getNetworkPoint().getBestAddress(src, chooser);
String host = InetAddresses.toAddrString(address);
URI uri;
try {
uri = new URI(scheme, null, host, port, null, null, null);
} catch (URISyntaxException e) {
throw new OpsException("Error building URI", e);
}
return uri;
}
Aggregations