Package org.apache.solr.client.solrj.routing

## Class NodePreferenceRulesComparator

- java.lang.Object
- - org.apache.solr.client.solrj.routing.NodePreferenceRulesComparator

    public class NodePreferenceRulesComparator
    extends Object

This comparator makes sure that the given replicas are sorted according to the given list of preferences. E.g. If all nodes prefer local cores then a bad/heavily-loaded node will receive fewer requests from healthy nodes. This will help prevent a distributed deadlock or timeouts in all the healthy nodes due to one bad node.

Optional final preferenceRule is *not* used for pairwise sorting, but instead defines how "equivalent" replicas will be ordered (the base ordering). Defaults to "random"; may specify "stable".

### Constructor Summary

Constructors
`NodePreferenceRulesComparator​(List<PreferenceRule> preferenceRules, SolrParams requestParams, String nodeName, String baseUrl, String hostName, NodesSysProps sysProps, ReplicaListTransformerFactory defaultRltFactory, ReplicaListTransformerFactory stableRltFactory)`
`NodePreferenceRulesComparator​(List<PreferenceRule> preferenceRules, SolrParams requestParams, ReplicaListTransformerFactory defaultRltFactory, ReplicaListTransformerFactory stableRltFactory)`

### Method Summary

All Methods Instance Methods Concrete Methods
`ReplicaListTransformer` `getBaseReplicaListTransformer()`
`<T> Comparator<T>` `getComparator​(T example)`
`List<PreferenceRule>` `getPreferenceRules()`
`Comparator<Replica>` `getReplicaComparator()`
`Comparator<String>` `getUrlComparator()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### NodePreferenceRulesComparator

    public NodePreferenceRulesComparator​(List<PreferenceRule> preferenceRules,
                                         SolrParams requestParams,
                                         ReplicaListTransformerFactory defaultRltFactory,
                                         ReplicaListTransformerFactory stableRltFactory)

#### NodePreferenceRulesComparator

    public NodePreferenceRulesComparator​(List<PreferenceRule> preferenceRules,
                                         SolrParams requestParams,
                                         String nodeName,
                                         String baseUrl,
                                         String hostName,
                                         NodesSysProps sysProps,
                                         ReplicaListTransformerFactory defaultRltFactory,
                                         ReplicaListTransformerFactory stableRltFactory)

### Method Detail

#### getBaseReplicaListTransformer

    public ReplicaListTransformer getBaseReplicaListTransformer()

#### getComparator

    public <T> Comparator<T> getComparator​(T example)

#### getReplicaComparator

    public Comparator<Replica> getReplicaComparator()

#### getUrlComparator

    public Comparator<String> getUrlComparator()

#### getPreferenceRules

    public List<PreferenceRule> getPreferenceRules()