This is an automated email from the ASF dual-hosted git repository.
epugh 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 594c2a40114 SOLR-18381: remove
ClusterState.getReplicaNamesPerCollectionOnNode (#4768)
594c2a40114 is described below
commit 594c2a4011461e8b443ec65e685d2f320c3c2d4a
Author: Serhiy Bzhezytskyy <[email protected]>
AuthorDate: Sat Sep 5 14:33:55 2026 +0300
SOLR-18381: remove ClusterState.getReplicaNamesPerCollectionOnNode (#4768)
Co-authored-by: Eric Pugh <[email protected]>
---
.../src/java/org/apache/solr/cloud/ZkController.java | 13 +++++++++++--
.../test/org/apache/solr/cloud/ZkControllerTest.java | 9 ++++-----
.../org/apache/solr/common/cloud/ClusterState.java | 18 ------------------
3 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index 3ab82e68b1d..112b301b62c 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -2975,8 +2975,17 @@ public class ZkController implements Closeable {
log.info("Publish node={} as DOWN", nodeName);
ClusterState clusterState = getClusterState();
- Map<String, List<Replica>> replicasPerCollectionOnNode =
- clusterState.getReplicaNamesPerCollectionOnNode(nodeName);
+ Map<String, List<Replica>> replicasPerCollectionOnNode = new HashMap<>();
+ clusterState
+ .collectionStream()
+ .forEach(
+ col -> {
+ List<Replica> replicas = col.getReplicasOnNode(nodeName);
+ if (!replicas.isEmpty()) {
+ replicasPerCollectionOnNode.put(col.getName(), replicas);
+ }
+ });
+
if (distributedClusterStateUpdater.isDistributedStateUpdate()) {
// Note that with the current implementation, when distributed cluster
state updates are
// enabled, we mark the node down synchronously from this thread,
whereas the Overseer cluster
diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
index 1d868787d48..53c9e3fd83e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
@@ -388,11 +388,10 @@ public class ZkControllerTest extends SolrCloudTestCase {
zkController.getZkStateReader().forciblyRefreshAllClusterStateSlow();
ClusterState clusterState = zkController.getClusterState();
- Map<String, List<Replica>> replicasOnNode =
- clusterState.getReplicaNamesPerCollectionOnNode(nodeName);
- assertNotNull("There should be replicas on the existing node",
replicasOnNode);
- List<Replica> replicas = replicasOnNode.get(collectionName);
- assertNotNull("There should be replicas for the collection on the
existing node", replicas);
+ List<Replica> replicas =
+
clusterState.getCollection(collectionName).getReplicasOnNode(nodeName);
+ assertFalse(
+ "There should be replicas for the collection on the existing
node", replicas.isEmpty());
assertEquals(
"Wrong number of replicas for the collection on the existing
node", 1, replicas.size());
for (Replica replica : replicas) {
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
index 40832f59b9d..36c3a3f7cb8 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
@@ -160,22 +159,6 @@ public class ClusterState implements MapWriter {
return liveNodes;
}
- @Deprecated(since = "10.0")
- public Map<String, List<Replica>> getReplicaNamesPerCollectionOnNode(final
String nodeName) {
- Map<String, List<Replica>> replicaNamesPerCollectionOnNode = new
HashMap<>();
- collectionStates.values().stream()
- .map(CollectionRef::get)
- .filter(Objects::nonNull)
- .forEach(
- col -> {
- List<Replica> replicas = col.getReplicasOnNode(nodeName);
- if (!replicas.isEmpty()) {
- replicaNamesPerCollectionOnNode.put(col.getName(), replicas);
- }
- });
- return replicaNamesPerCollectionOnNode;
- }
-
/** Check if node is alive. */
public boolean liveNodesContain(String name) {
return liveNodes.contains(name);
@@ -190,7 +173,6 @@ public class ClusterState implements MapWriter {
return sb.toString();
}
- @Deprecated
public static ClusterState createFromCollectionMap(
int version,
Map<String, Object> stateMap,