Source:
<code>public Pair<String, ServerDiscoverySelector> select(final Query<T> query) { synchronized (lock) { if (!ruleManager.isStarted() || !started) { return getDefaultLookup(); } } String brokerServiceName = null; for (TieredBrokerSelectorStrategy strategy : strategies) { final Optional<String> optionalName = strategy.getBrokerServiceName(tierConfig, query); if (optionalName.isPresent()) { brokerServiceName = optionalName.get(); break; } } if (brokerServiceName == null) { List<Rule> rules = ruleManager.getRulesWithDefault(Iterables.getFirst(query.getDataSource().getNames(), null)); DateTime now = new DateTime(); int lastRulePosition = -1; LoadRule baseRule = null; for (Interval interval : query.getIntervals()) { int currRulePosition = 0; for (Rule rule : rules) { if (rule instanceof LoadRule && currRulePosition > lastRulePosition && rule.appliesTo(interval, now)) { lastRulePosition = currRulePosition; baseRule = (LoadRule) rule; break; } currRulePosition++; } } if (baseRule == null) { return getDefaultLookup(); } for (Map.Entry<String, String> entry : tierConfig.getTierToBrokerMap().entrySet()) { if (baseRule.getTieredReplicants().containsKey(entry.getKey())) { brokerServiceName = entry.getValue(); break; } } } if (brokerServiceName == null) { log.error( "WTF?! No brokerServiceName found for datasource[%s], intervals[%s]. Using default[%s].", query.getDataSource(), query.getIntervals(), tierConfig.getDefaultBrokerServiceName() ); brokerServiceName = tierConfig.getDefaultBrokerServiceName(); } <START> ServerDiscoverySelector retVal = selectorMap.get(brokerServiceName); <END> if (retVal == null) { log.error( "WTF?! No selector found for brokerServiceName[%s]. Using default selector for[%s]", brokerServiceName, tierConfig.getDefaultBrokerServiceName() ); retVal = selectorMap.get(CuratorServiceUtils.makeCanonicalServiceName(tierConfig.getDefaultBrokerServiceName())); } return new Pair<>(brokerServiceName, retVal); }</code><technical_language>Integration-tests failing discover broker this change, other fixes else handle this</technical_language>

Target:
public Pair<String, ServerDiscoverySelector> select(final Query<T> query) { synchronized (lock) { if (!ruleManager.isStarted() || !started) { return getDefaultLookup(); } } String brokerServiceName = null; for (TieredBrokerSelectorStrategy strategy : strategies) { final Optional<String> optionalName = strategy.getBrokerServiceName(tierConfig, query); if (optionalName.isPresent()) { brokerServiceName = optionalName.get(); break; } } if (brokerServiceName == null) { List<Rule> rules = ruleManager.getRulesWithDefault(Iterables.getFirst(query.getDataSource().getNames(), null)); DateTime now = new DateTime(); int lastRulePosition = -1; LoadRule baseRule = null; for (Interval interval : query.getIntervals()) { int currRulePosition = 0; for (Rule rule : rules) { if (rule instanceof LoadRule && currRulePosition > lastRulePosition && rule.appliesTo(interval, now)) { lastRulePosition = currRulePosition; baseRule = (LoadRule) rule; break; } currRulePosition++; } } if (baseRule == null) { return getDefaultLookup(); } for (Map.Entry<String, String> entry : tierConfig.getTierToBrokerMap().entrySet()) { if (baseRule.getTieredReplicants().containsKey(entry.getKey())) { brokerServiceName = entry.getValue(); break; } } } if (brokerServiceName == null) { log.error( "WTF?! No brokerServiceName found for datasource[%s], intervals[%s]. Using default[%s].", query.getDataSource(), query.getIntervals(), tierConfig.getDefaultBrokerServiceName() ); brokerServiceName = tierConfig.getDefaultBrokerServiceName(); } ServerDiscoverySelector retVal = selectorMap.get(brokerServiceName); if (retVal == null) { log.error( "WTF?! No selector found for brokerServiceName[%s]. Using default selector for[%s]", brokerServiceName, tierConfig.getDefaultBrokerServiceName() ); retVal = selectorMap.get(tierConfig.getDefaultBrokerServiceName()); } return new Pair<>(brokerServiceName, retVal); }