Proposed patch against trunk to follow. No change in behaviour intended. This would be as a step towards SOLR-6730.
SOLR-6730 select?replicaAffinity=(node|host) and replicaAffinity.hostPriorities support
SOLR-9758 refactor preferLocalShards implementation
GitHub Pull Request #102