You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2024/05/01 19:38:41 UTC

(solr) branch main updated: SOLR-17257: Avoid instantiating NodeStateProvider several times when computing replica placement (#2420)

This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new b7d4ef867a4 SOLR-17257: Avoid instantiating NodeStateProvider several times when computing replica placement (#2420)
b7d4ef867a4 is described below

commit b7d4ef867a465d142e6be4506372589bb62f0690
Author: Yohann Callea <yc...@salesforce.com>
AuthorDate: Wed May 1 21:38:36 2024 +0200

    SOLR-17257: Avoid instantiating NodeStateProvider several times when computing replica placement (#2420)
    
    Both Minimize Cores and the Affinity replica placement strategies would over-gather cluster metrics.  AttributeFetcherImpl was improved accordingly.
---
 solr/CHANGES.txt                                                 | 3 ++-
 .../apache/solr/cluster/placement/impl/AttributeFetcherImpl.java | 9 +++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 01c7e6efab8..c2104977d57 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -108,7 +108,8 @@ Improvements
 
 Optimizations
 ---------------------
-(No changes)
+* SOLR-17257: Both Minimize Cores and the Affinity replica placement strategies would over-gather
+  cluster metrics.  AttributeFetcherImpl was improved accordingly.  (Yohann Callea)
 
 Bug Fixes
 ---------------------
diff --git a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
index 251dd49759d..8ac3f9ab0c6 100644
--- a/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
+++ b/solr/core/src/java/org/apache/solr/cluster/placement/impl/AttributeFetcherImpl.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.function.BiConsumer;
 import java.util.stream.Collectors;
+import org.apache.solr.client.solrj.cloud.NodeStateProvider;
 import org.apache.solr.client.solrj.cloud.SolrCloudManager;
 import org.apache.solr.client.solrj.impl.NodeValueFetcher;
 import org.apache.solr.cluster.Node;
@@ -138,14 +139,14 @@ public class AttributeFetcherImpl implements AttributeFetcher {
                               }));
         });
 
+    final NodeStateProvider nodeStateProvider = cloudManager.getNodeStateProvider();
+
     // Now that we know everything we need to fetch (and where to put it), just do it.
     // TODO: we could probably fetch this in parallel - for large clusters this could
     // significantly shorten the execution time
     for (Node node : nodes) {
       Map<String, Object> tagValues =
-          cloudManager
-              .getNodeStateProvider()
-              .getNodeValues(node.getName(), allSnitchTagsToInsertion.keySet());
+          nodeStateProvider.getNodeValues(node.getName(), allSnitchTagsToInsertion.keySet());
       for (Map.Entry<String, Object> e : tagValues.entrySet()) {
         String tag = e.getKey();
         Object value = e.getValue(); // returned value from the node
@@ -163,7 +164,7 @@ public class AttributeFetcherImpl implements AttributeFetcher {
     for (Node node : nodeToReplicaInternalTags.keySet()) {
       Set<String> tags = nodeToReplicaInternalTags.get(node);
       Map<String, Map<String, List<Replica>>> infos =
-          cloudManager.getNodeStateProvider().getReplicaInfo(node.getName(), tags);
+          nodeStateProvider.getReplicaInfo(node.getName(), tags);
       infos.entrySet().stream()
           .filter(entry -> requestedCollectionNamesMetrics.containsKey(entry.getKey()))
           .forEach(