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. URL: https://github.com/apache/bookkeeper/pull/425#discussion_r133079883
########## File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java ########## @@ -93,6 +103,62 @@ public void reloadCachedMappings() { } + /** + * Decorator for any existing dsn resolver. + * Backfills returned data with appropriate default rack info. + */ + static class DNSResolverDecorator implements DNSToSwitchMapping { + + final Supplier<String> defaultRackSupplier; + final DNSToSwitchMapping resolver; + + DNSResolverDecorator(DNSToSwitchMapping resolver, Supplier<String> defaultRackSupplier) { + Preconditions.checkNotNull(resolver, "Resolver cannot be null"); + Preconditions.checkNotNull(defaultRackSupplier, "defaultRackSupplier should not be null"); + this.defaultRackSupplier = defaultRackSupplier; + this.resolver= resolver; + } + + public List<String> resolve(List<String> names) { + if (names == null) { + return new ArrayList<>(); Review comment: use Collections.emptyList() to avoid constructing an object here. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services