func findSolrNodeContents(cluster solr_api.SolrClusterStatus, overseerLeader string) (nodeContents map[string]*SolrNodeContents, totalShardReplicas map[string]int, shardReplicasNotActive map[string]int) {
	nodeContents = map[string]*SolrNodeContents{}
	totalShardReplicas = map[string]int{}
	shardReplicasNotActive = map[string]int{}
	// Update the info for each "live" node.
	for _, nodeName := range cluster.LiveNodes {
		contents, hasValue := nodeContents[nodeName]
		if !hasValue {
			contents = &SolrNodeContents{
				nodeName:               nodeName,
				leaders:                0,
				replicas:               0,
				totalReplicasPerShard:  map[string]int{},
				activeReplicasPerShard: map[string]int{},
				downReplicasPerShard:   map[string]int{},
				overseerLeader:         false,
				live:                   true,
			}
		} else {
			contents.live = true
		}
		nodeContents[nodeName] = contents
	}
	// Go through the state of each collection getting the count of replicas for each collection/shard living on each node
	for collectionName, collection := range cluster.Collections {
		for shardName, shard := range collection.Shards {
			uniqueShard := collectionName + "|" + shardName
			totalShardReplicas[uniqueShard] = len(shard.Replicas)
			for _, replica := range shard.Replicas {
				contents, hasValue := nodeContents[replica.NodeName]
				if !hasValue {
					contents = &SolrNodeContents{
						nodeName:               replica.NodeName,
						leaders:                0,
						replicas:               0,
						totalReplicasPerShard:  map[string]int{},
						activeReplicasPerShard: map[string]int{},
						downReplicasPerShard:   map[string]int{},
						overseerLeader:         false,
						live:                   false,
					}
				}
				if replica.Leader {
					contents.leaders += 1
				}
				contents.replicas += 1
				contents.totalReplicasPerShard[uniqueShard] += 1

				// A replica can be considered "not active" if it's state is not "active" or the node it lives in is not "live".
				if !(replica.State == solr_api.ReplicaActive && contents.live) {
					shardReplicasNotActive[uniqueShard] += 1
				}
				if replica.State == solr_api.ReplicaActive {
					contents.activeReplicasPerShard[uniqueShard] += 1
				}
				// Keep track of how many of the replicas of this shard are in a down state (down or recovery_failed)
				if replica.State == solr_api.ReplicaDown || replica.State == solr_api.ReplicaRecoveryFailed {
					contents.downReplicasPerShard[uniqueShard] += 1
				} else {
					contents.notDownReplicas += 1
				}

				nodeContents[replica.NodeName] = contents
			}
		}
	}
	// Update the info for the overseerLeader leader.
	if overseerLeader != "" {
		contents, hasValue := nodeContents[overseerLeader]
		if !hasValue {
			contents = &SolrNodeContents{
				nodeName:               overseerLeader,
				leaders:                0,
				totalReplicasPerShard:  map[string]int{},
				activeReplicasPerShard: map[string]int{},
				downReplicasPerShard:   map[string]int{},
				overseerLeader:         true,
				live:                   false,
			}
		} else {
			contents.overseerLeader = true
		}
		nodeContents[overseerLeader] = contents
	}
	return nodeContents, totalShardReplicas, shardReplicasNotActive
}
/*
findSolrNodeContents will take a cluster and overseerLeader response from the SolrCloud Collections API, and aggregate the information.
This aggregated info is returned as:
	- A map from Solr nodeName to SolrNodeContents, with the information from the clusterState and overseerLeader
    - A map from unique shard name (collection+shard) to the count of replicas that are not active for that shard.
      - If a node is not live, then all shards that live on that node will be considered "not active"
*/
findSolrNodeContents will take a cluster and overseerLeader response from the SolrCloud Collections API, and aggregate the information.
This aggregated info is returned as:
A map from Solr nodeName to SolrNodeContents, with the information from the clusterState and overseerLeader
A map from unique shard name (collection+shard) to the count of replicas that are not active for that shard.
If a node is not live, then all shards that live on that node will be considered "not active"
/ * findSolrNodeContents will take a cluster and overseerLeader response from the SolrCloud Collections API and aggregate the information . This aggregated info is returned as : - A map from Solr nodeName to SolrNodeContents with the information from the clusterState and overseerLeader - A map from unique shard name ( collection + shard ) to the count of replicas that are not active for that shard . - If a node is not live then all shards that live on that node will be considered " not active " * /
func findSolrNodeContents(cluster solr_api.SolrClusterStatus, overseerLeader string) (nodeContents map[string]*SolrNodeContents, totalShardReplicas map[string]int, shardReplicasNotActive map[string]int) {
	nodeContents = map[string]*SolrNodeContents{}
	totalShardReplicas = map[string]int{}
	shardReplicasNotActive = map[string]int{}
	for _, nodeName := range cluster.LiveNodes {
		contents, hasValue := nodeContents[nodeName]
		if !hasValue {
			contents = &SolrNodeContents{
				nodeName:               nodeName,
				leaders:                0,
				replicas:               0,
				totalReplicasPerShard:  map[string]int{},
				activeReplicasPerShard: map[string]int{},
				downReplicasPerShard:   map[string]int{},
				overseerLeader:         false,
				live:                   true,
			}
		} else {
			contents.live = true
		}
		nodeContents[nodeName] = contents
	}
	for collectionName, collection := range cluster.Collections {
		for shardName, shard := range collection.Shards {
			uniqueShard := collectionName + "|" + shardName
			totalShardReplicas[uniqueShard] = len(shard.Replicas)
			for _, replica := range shard.Replicas {
				contents, hasValue := nodeContents[replica.NodeName]
				if !hasValue {
					contents = &SolrNodeContents{
						nodeName:               replica.NodeName,
						leaders:                0,
						replicas:               0,
						totalReplicasPerShard:  map[string]int{},
						activeReplicasPerShard: map[string]int{},
						downReplicasPerShard:   map[string]int{},
						overseerLeader:         false,
						live:                   false,
					}
				}
				if replica.Leader {
					contents.leaders += 1
				}
				contents.replicas += 1
				contents.totalReplicasPerShard[uniqueShard] += 1
				if !(replica.State == solr_api.ReplicaActive && contents.live) {
					shardReplicasNotActive[uniqueShard] += 1
				}
				if replica.State == solr_api.ReplicaActive {
					contents.activeReplicasPerShard[uniqueShard] += 1
				}
				if replica.State == solr_api.ReplicaDown || replica.State == solr_api.ReplicaRecoveryFailed {
					contents.downReplicasPerShard[uniqueShard] += 1
				} else {
					contents.notDownReplicas += 1
				}
				nodeContents[replica.NodeName] = contents
			}
		}
	}
	if overseerLeader != "" {
		contents, hasValue := nodeContents[overseerLeader]
		if !hasValue {
			contents = &SolrNodeContents{
				nodeName:               overseerLeader,
				leaders:                0,
				totalReplicasPerShard:  map[string]int{},
				activeReplicasPerShard: map[string]int{},
				downReplicasPerShard:   map[string]int{},
				overseerLeader:         true,
				live:                   false,
			}
		} else {
			contents.overseerLeader = true
		}
		nodeContents[overseerLeader] = contents
	}
	return nodeContents, totalShardReplicas, shardReplicasNotActive
}
func findSolrNodeContents ( cluster solr_api . SolrClusterStatus , overseerLeader string ) ( nodeContents map [ string ] * SolrNodeContents , totalShardReplicas map [ string ] int , shardReplicasNotActive map [ string ] int ) { nodeContents = map [ string ] * SolrNodeContents { } totalShardReplicas = map [ string ] int { } shardReplicasNotActive = map [ string ] int { } for _ , nodeName := range cluster . LiveNodes { contents , hasValue := nodeContents [ nodeName ] if ! hasValue { contents = & SolrNodeContents { nodeName : nodeName , leaders : 0 , replicas : 0 , totalReplicasPerShard : map [ string ] int { } , activeReplicasPerShard : map [ string ] int { } , downReplicasPerShard : map [ string ] int { } , overseerLeader : false , live : true , } } else { contents . live = true } nodeContents [ nodeName ] = contents } for collectionName , collection := range cluster . Collections { for shardName , shard := range collection . Shards { uniqueShard := collectionName + " " + shardName totalShardReplicas [ uniqueShard ] = len ( shard . Replicas ) for _ , replica := range shard . Replicas { contents , hasValue := nodeContents [ replica . NodeName ] if ! hasValue { contents = & SolrNodeContents { nodeName : replica . NodeName , leaders : 0 , replicas : 0 , totalReplicasPerShard : map [ string ] int { } , activeReplicasPerShard : map [ string ] int { } , downReplicasPerShard : map [ string ] int { } , overseerLeader : false , live : false , } } if replica . Leader { contents . leaders += 1 } contents . replicas += 1 contents . totalReplicasPerShard [ uniqueShard ] += 1 if ! ( replica . State == solr_api . ReplicaActive && contents . live ) { shardReplicasNotActive [ uniqueShard ] += 1 } if replica . State == solr_api . ReplicaActive { contents . activeReplicasPerShard [ uniqueShard ] += 1 } if replica . State == solr_api . ReplicaDown || replica . State == solr_api . ReplicaRecoveryFailed { contents . downReplicasPerShard [ uniqueShard ] += 1 } else { contents . notDownReplicas += 1 } nodeContents [ replica . NodeName ] = contents } } } if overseerLeader != " " { contents , hasValue := nodeContents [ overseerLeader ] if ! hasValue { contents = & SolrNodeContents { nodeName : overseerLeader , leaders : 0 , totalReplicasPerShard : map [ string ] int { } , activeReplicasPerShard : map [ string ] int { } , downReplicasPerShard : map [ string ] int { } , overseerLeader : true , live : false , } } else { contents . overseerLeader = true } nodeContents [ overseerLeader ] = contents } return nodeContents , totalShardReplicas , shardReplicasNotActive }
findSolrNodeContents will take a cluster and overseerLeader response from the SolrCloud Collections API, and aggregate the information.
findSolrNodeContents will take a cluster and overseerLeader response from the SolrCloud Collections API and aggregate the information .
// Update the info for each "live" node. // Go through the state of each collection getting the count of replicas for each collection/shard living on each node // A replica can be considered "not active" if it's state is not "active" or the node it lives in is not "live". // Keep track of how many of the replicas of this shard are in a down state (down or recovery_failed) // Update the info for the overseerLeader leader.