From 7c101fba4a38e8cd1240d2ee057dc0329f52fea1 Mon Sep 17 00:00:00 2001 From: Anshum Gupta Date: Wed, 28 Aug 2019 08:47:25 -0700 Subject: [PATCH] SOLR-13257: Cleanup code and make the AffinityReplicaTransformer constructors private (#848) (#849) SOLR-13257: Cleanup code and make the constructors private as the constructor is supposed to be called via the static getInstance method. --- .../AffinityReplicaListTransformer.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/component/AffinityReplicaListTransformer.java b/solr/core/src/java/org/apache/solr/handler/component/AffinityReplicaListTransformer.java index 94334f27b06..420c1110baa 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/AffinityReplicaListTransformer.java +++ b/solr/core/src/java/org/apache/solr/handler/component/AffinityReplicaListTransformer.java @@ -16,17 +16,15 @@ */ package org.apache.solr.handler.component; -import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.ListIterator; + import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.Hash; import org.apache.solr.request.SolrQueryRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Allows better caching by establishing deterministic evenly-distributed replica routing preferences according to @@ -35,15 +33,13 @@ import org.slf4j.LoggerFactory; */ class AffinityReplicaListTransformer implements ReplicaListTransformer { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final int routingDividend; - public AffinityReplicaListTransformer(String hashVal) { + private AffinityReplicaListTransformer(String hashVal) { this.routingDividend = Math.abs(Hash.lookup3ycs(hashVal, 0, hashVal.length(), 0)); } - public AffinityReplicaListTransformer(int routingDividend) { + private AffinityReplicaListTransformer(int routingDividend) { this.routingDividend = routingDividend; } @@ -107,12 +103,5 @@ class AffinityReplicaListTransformer implements ReplicaListTransformer { } - private static final Comparator SORTABLE_CHOICE_COMPARATOR = new Comparator() { - - @Override - public int compare(SortableChoice o1, SortableChoice o2) { - return o1.sortableCoreLabel.compareTo(o2.sortableCoreLabel); - } - }; - + private static final Comparator SORTABLE_CHOICE_COMPARATOR = Comparator.comparing(o -> o.sortableCoreLabel); }