fun preComputeBestReplicaMapping() { val collectionToShardToCoreMapping: Map<String, Map<String, Map<String, String>>> = getZkClusterData().getCollectionToShardToCoreMapping() for (collection in collectionNames) { val shardToCoreMapping = collectionToShardToCoreMapping[collection]!! for (shard in shardToCoreMapping.keys) { val coreToNodeMap = shardToCoreMapping[shard]!! for (core in coreToNodeMap.keys) { val node = coreToNodeMap[core] val currentReplica = SolrCore(node, core) try { currentReplica.loadStatus() fillUpAllCoresForShard(currentReplica, coreToNodeMap) break } catch (e: Exception) { logger.info(ExceptionUtils.getFullStackTrace(e)) continue } } shardToBestReplicaMapping.put(shard, coreToBestReplicaMappingByHealth) } } }
For all the collections in zookeeper , compute the best replica for every shard for every collection . Doing this computation at bootup significantly reduces the computation done during streaming .