You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by no...@apache.org on 2022/11/08 06:23:12 UTC
[solr] branch branch_9x updated: SOLR-16414: simplified code
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 1d7b7795cc7 SOLR-16414: simplified code
1d7b7795cc7 is described below
commit 1d7b7795cc77ad6863832e3a87d144a68490ba06
Author: Noble Paul <no...@gmail.com>
AuthorDate: Tue Nov 8 17:22:08 2022 +1100
SOLR-16414: simplified code
---
.../java/org/apache/solr/cloud/ZkController.java | 50 ++++++++--------------
1 file changed, 19 insertions(+), 31 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 2b3062ddf82..3aa86c43953 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -2933,40 +2933,28 @@ public class ZkController implements Closeable {
} else {
try {
// Create a concurrently accessible set to avoid repeating collections
- Set<String> collectionsInThisNode = new HashSet<>();
+ Set<String> processedCollections = new HashSet<>();
for (CoreDescriptor cd : cc.getCoreDescriptors()) {
- if (cd.getCloudDescriptor() != null
- && cd.getCloudDescriptor().getCollectionName() != null) {
- collectionsInThisNode.add(cd.getCloudDescriptor().getCollectionName());
+ String collName = cd.getCollectionName();
+ DocCollection coll;
+ if (collName != null
+ && processedCollections.add(collName)
+ && (coll = zkStateReader.getCollection(collName)) != null
+ && coll.isPerReplicaState()) {
+ final List<String> replicasToDown = new ArrayList<>();
+ coll.forEachReplica(
+ (s, replica) -> {
+ if (replica.getNodeName().equals(nodeName)) {
+ replicasToDown.add(replica.getName());
+ }
+ });
+ PerReplicaStatesOps.downReplicas(
+ replicasToDown,
+ PerReplicaStatesFetcher.fetch(
+ coll.getZNode(), zkClient, coll.getPerReplicaStates()))
+ .persist(coll.getZNode(), zkClient);
}
}
- collectionsInThisNode.forEach(
- c -> {
- final List<String> replicasToDown = new ArrayList<>();
- DocCollection coll = zkStateReader.getCollection(c);
- if (coll == null) {
- // may be the collection no more exists
- return;
- }
- coll.forEachReplica(
- (s, r) -> {
- if (r.getNodeName().equals(nodeName)) {
- replicasToDown.add(r.getName());
- }
- });
-
- if (!replicasToDown.isEmpty()) {
- try {
- PerReplicaStatesOps.downReplicas(
- replicasToDown,
- PerReplicaStatesFetcher.fetch(
- coll.getZNode(), zkClient, coll.getPerReplicaStates()))
- .persist(coll.getZNode(), zkClient);
- } catch (KeeperException | InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- });
// We always send a down node event to overseer to be safe, but overseer will not need to do
// anything for PRS collections