use of org.apache.knox.gateway.topology.discovery.DefaultServiceDiscoveryConfig in project knox by apache.
the class SimpleDescriptorHandler method performDiscovery.
private static ServiceDiscovery.Cluster performDiscovery(GatewayConfig config, SimpleDescriptor desc, Service... gatewayServices) {
DefaultServiceDiscoveryConfig sdc = new DefaultServiceDiscoveryConfig(desc.getDiscoveryAddress());
sdc.setUser(desc.getDiscoveryUser());
sdc.setPasswordAlias(desc.getDiscoveryPasswordAlias());
// Use the discovery type from the descriptor. If it's unspecified, employ the default type.
String discoveryType = desc.getDiscoveryType();
if (discoveryType == null) {
discoveryType = DEFAULT_DISCOVERY_TYPE;
}
// Use the cached discovery object for the required type, if it has already been loaded
ServiceDiscovery sd = discoveryInstances.get(discoveryType);
if (sd == null) {
sd = ServiceDiscoveryFactory.get(discoveryType, gatewayServices);
discoveryInstances.put(discoveryType, sd);
}
return sd.discover(config, sdc, desc.getClusterName());
}
Aggregations