sijie commented on a change in pull request #425: BOOKKEEPER-1105: 
RackAwarePolicy: Failure to map node into rack may result in failure to add 
other nodes.

 File path: 
 @@ -41,14 +41,14 @@
      * <p/>
      * If a name cannot be resolved to a rack, the implementation
-     * should return {@link NetworkTopology#DEFAULT_RACK}. This
+     * should return {@link NetworkTopology#DEFAULT_REGION_AND_RACK}. This
      * is what the bundled implementations do, though it is not a formal 
      * @param names the list of hosts to resolve (can be empty)
      * @return list of resolved network paths.
      * If <i>names</i> is empty, the returned list is also empty
-    public List<String> resolve(List<String> names);
+    public List<String> resolve(List<String> names, String defaultRack);
 Review comment:
   This would break the binary compatibility for any people who implemented 
   The main problem is 
       public static String resolveNetworkLocation(DNSToSwitchMapping 
dnsResolver, InetSocketAddress addr) {
           List<String> names = new ArrayList<String>(1);
           if (dnsResolver instanceof CachedDNSToSwitchMapping) {
           } else {
           // resolve network addresses
           List<String> rNames = dnsResolver.resolve(names);
           String netLoc;
           if (null == rNames) {
               logger.warn("Failed to resolve network location for {}, using 
default rack for them : {}.", names,
               netLoc = NetworkTopology.DEFAULT_RACK;
           } else {
               netLoc = rNames.get(0);
           return netLoc;
   I think a clean solution without breaking the binary compatibility is
   - Fix the DefaultResolver to allow passing in a `defaultRack` 
   class DefaultResolver {
       final String defaultRack = ...;
      DefaultResolver() {
      DefaultResolver(String defaultRack) {
          this.defaultRack = defaultRack;
   the rackware can use new DefaultResolver(`/default-rack`) and regionaware 
can use new DefaultResolver(`/default-region/default-rack`)
   - create a DNSResolverDelegator with default-rack and remove the logic 
`NetUtils#resolveNetworkLocation` to this delegator.
   class DNSResolverDelegator extends DefaultResolver {
       DNSToSwitchMapping resolver;
        DNSResolverDelegator(DNSToSwitchMapping resolver, String defaultRack) {
             this.resolver= resolver;
        List<String> resolve(List<String> names) {
           List<String> resolvedNames = resolver.resolve(names);
           if (null == resolvedNames) {
               // return default rack
   - on initialization
           if (optionalDnsResolver.isPresent()) {
               dnsResolver = optionalDnsResolver.get();
           } else {
               String dnsResolverName = conf.getString(REPP_DNS_RESOLVER_CLASS, 
               try {
                   dnsResolver = ReflectionUtils.newInstance(dnsResolverName, 
                   if (dnsResolver instanceof Configurable) {
                       ((Configurable) dnsResolver).setConf(conf);
               } catch (RuntimeException re) {
         "Failed to initialize DNS Resolver {}, used default 
subnet resolver.", dnsResolverName, re);
                   dnsResolver = new DefaultResolver(`default-rack`); // <= add 
default rack
           this.dnsResolver = new DNSResolverDelegator(dnsResolver, 
   In this way you don't need to change the signature of the methods. How does 
that sound?
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

Reply via email to