Skip to content

Commit

Permalink
Merge pull request #26 from unbxd/SSK-2764
Browse files Browse the repository at this point in the history
[SSK-2764/SOLR-10720] fix: patch clusterstatus
  • Loading branch information
apoorvprecisely authored Aug 11, 2021
2 parents a68c6e1 + 7fb6b06 commit f84e530
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
Expand Down Expand Up @@ -344,38 +343,6 @@ private void balanceProperty(ClusterState clusterState, ZkNodeProps message, Nam
inQueue.offer(Utils.toJSON(new ZkNodeProps(propMap)));
}

/**
* Walks the tree of collection status to verify that any replicas not reporting a "down" status is
* on a live node, if any replicas reporting their status as "active" but the node is not live is
* marked as "down"; used by CLUSTERSTATUS.
* @param liveNodes List of currently live node names.
* @param collectionProps Map of collection status information pulled directly from ZooKeeper.
*/

@SuppressWarnings("unchecked")
protected void crossCheckReplicaStateWithLiveNodes(List<String> liveNodes, NamedList<Object> collectionProps) {
Iterator<Map.Entry<String,Object>> colls = collectionProps.iterator();
while (colls.hasNext()) {
Map.Entry<String,Object> next = colls.next();
Map<String,Object> collMap = (Map<String,Object>)next.getValue();
Map<String,Object> shards = (Map<String,Object>)collMap.get("shards");
for (Object nextShard : shards.values()) {
Map<String,Object> shardMap = (Map<String,Object>)nextShard;
Map<String,Object> replicas = (Map<String,Object>)shardMap.get("replicas");
for (Object nextReplica : replicas.values()) {
Map<String,Object> replicaMap = (Map<String,Object>)nextReplica;
if (Replica.State.getState((String) replicaMap.get(ZkStateReader.STATE_PROP)) != Replica.State.DOWN) {
// not down, so verify the node is live
String node_name = (String)replicaMap.get(ZkStateReader.NODE_NAME_PROP);
if (!liveNodes.contains(node_name)) {
// node is not live, so this replica is actually down
replicaMap.put(ZkStateReader.STATE_PROP, Replica.State.DOWN.toString());
}
}
}
}
}
}

/**
* Get collection status from cluster state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,19 @@ public void getClusterStatus(NamedList results)
if (collectionVsAliases.containsKey(name) && !collectionVsAliases.get(name).isEmpty()) {
collectionStatus.put("aliases", collectionVsAliases.get(name));
}
String configName = zkStateReader.readConfigName(name);
collectionStatus.put("configName", configName);
collectionProps.add(name, collectionStatus);
}

try {
String configName = zkStateReader.readConfigName(name);
collectionStatus.put("configName", configName);
collectionProps.add(name, collectionStatus);
} catch (SolrException e) {
if (e.getCause() instanceof KeeperException.NoNodeException) {
// skip this collection because the collection's znode has been deleted
// which can happen during aggressive collection removal, see SOLR-10720
} else throw e;
}

}

List<String> liveNodes = zkStateReader.getZkClient().getChildren(ZkStateReader.LIVE_NODES_ZKNODE, null, true);

Expand Down

0 comments on commit f84e530

Please sign in to comment.