Search in sources :

Example 1 with DefaultServiceDiscoveryConfig

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());
}
Also used : DefaultServiceDiscoveryConfig(org.apache.knox.gateway.topology.discovery.DefaultServiceDiscoveryConfig) ServiceDiscovery(org.apache.knox.gateway.topology.discovery.ServiceDiscovery)

Aggregations

DefaultServiceDiscoveryConfig (org.apache.knox.gateway.topology.discovery.DefaultServiceDiscoveryConfig)1 ServiceDiscovery (org.apache.knox.gateway.topology.discovery.ServiceDiscovery)1