Merge pull request #958 from metamx/fix-router-service-discovery

fix router discovering brokers with default names
This commit is contained in:
Fangjin Yang 2014-12-15 13:35:39 -07:00
commit 31cda0b830
2 changed files with 19 additions and 4 deletions

View File

@ -21,7 +21,22 @@ package io.druid.curator.discovery;
public class CuratorServiceUtils
{
public static String makeCanonicalServiceName(String serviceName) {
/**
* Replacing '/' with ':' in service names makes it easier to provide an HTTP interface using
* <a href="http://curator.apache.org/curator-x-discovery-server/">curator-x-discovery-server</a>
*
* This method is marked protected because it should never be used outside of the io.druid.curator.discovery
* package. If you are tempted to use this method anywhere else you are most likely doing something wrong.
* Mapping the actual service name to the name used within curator should be left to {@link CuratorServiceAnnouncer}
* and {@link ServerDiscoveryFactory}
*
* @see io.druid.curator.discovery.CuratorServiceAnnouncer
* @see io.druid.curator.discovery.ServerDiscoveryFactory
*
* @param serviceName
* @return
*/
protected static String makeCanonicalServiceName(String serviceName) {
return serviceName.replaceAll("/", ":");
}
}

View File

@ -184,7 +184,7 @@ public class TieredBrokerHostSelector<T> implements HostSelector<T>
brokerServiceName = tierConfig.getDefaultBrokerServiceName();
}
ServerDiscoverySelector retVal = selectorMap.get(CuratorServiceUtils.makeCanonicalServiceName(brokerServiceName));
ServerDiscoverySelector retVal = selectorMap.get(brokerServiceName);
if (retVal == null) {
log.error(
@ -192,7 +192,7 @@ public class TieredBrokerHostSelector<T> implements HostSelector<T>
brokerServiceName,
tierConfig.getDefaultBrokerServiceName()
);
retVal = selectorMap.get(CuratorServiceUtils.makeCanonicalServiceName(tierConfig.getDefaultBrokerServiceName()));
retVal = selectorMap.get(tierConfig.getDefaultBrokerServiceName());
}
return new Pair<>(brokerServiceName, retVal);
@ -201,7 +201,7 @@ public class TieredBrokerHostSelector<T> implements HostSelector<T>
public Pair<String, ServerDiscoverySelector> getDefaultLookup()
{
final String brokerServiceName = tierConfig.getDefaultBrokerServiceName();
final ServerDiscoverySelector retVal = selectorMap.get(CuratorServiceUtils.makeCanonicalServiceName(brokerServiceName));
final ServerDiscoverySelector retVal = selectorMap.get(brokerServiceName);
return new Pair<>(brokerServiceName, retVal);
}
}