in gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariCluster.java [155:199]
public ZooKeeperConfig getZooKeeperConfiguration(String serviceName) {
ZooKeeperConfig result = null;
String config = zooKeeperHAConfigMappings.getProperty(serviceName + ".config");
if (config != null) {
String[] parts = config.split(":");
if (parts.length == 2) {
ServiceConfiguration sc = getServiceConfiguration(parts[0], parts[1]);
if (sc != null) {
String enabledProp = zooKeeperHAConfigMappings.getProperty(serviceName + ".enabled");
String ensembleProp = zooKeeperHAConfigMappings.getProperty(serviceName + ".ensemble");
String portProp = zooKeeperHAConfigMappings.getProperty(serviceName + ".port");
String namespaceProp = zooKeeperHAConfigMappings.getProperty(serviceName + ".namespace");
Map<String, String> scProps = sc.getProperties();
if (scProps != null) {
if (ensembleProp != null) {
// If there are multiple ensemble properties specified, then iteratively check for the first
// valid value, and use that one.
String[] ensembleProps = ensembleProp.split(",");
if (ensembleProps.length > 1) {
for (String prop : ensembleProps) {
if (!prop.isEmpty()) {
String value = scProps.get(prop);
if (value != null) {
ensembleProp = prop;
break;
}
}
}
}
}
result =
new ZooKeeperConfiguration(enabledProp != null ? scProps.get(enabledProp) : null,
ensembleProp != null ? scProps.get(ensembleProp) : null,
portProp != null ? scProps.get(portProp) : null,
namespaceProp != null ? scProps.get(namespaceProp) : null);
}
}
}
}
return result;
}