//IDictionary<string, ClusterInfo> _clusterMetaData = new Dictionary<string, ClusterInfo>(); public void AddDistributionStrategy(string cluster, string database, string collection, IDistributionStrategy strategy, DistributionStrategyConfiguration configuration, Boolean needTransfer) { ClusterInfo clusterInfo = (ClusterInfo)_clusterMetaData[cluster]; if (clusterInfo.Databases != null) { DatabaseInfo databaseInfo = clusterInfo.GetDatabase(database); CollectionInfo collectionInfo = databaseInfo.GetCollection(collection); collectionInfo.SetDistributionStrategy(configuration, strategy); if (collectionInfo.DistributionStrategy.Name.Equals(DistributionType.NonSharded.ToString())) { collectionInfo.DistributionStrategy.AddShard(collectionInfo.CollectionShard, null, needTransfer); //In case of NonShardedDistributionStrategy: The shard told by user must be added first. That is why this check is placed } _clusterMetaData[cluster] = clusterInfo; _configurationStore.InsertOrUpdateDistributionStrategy(clusterInfo, database, collection); } }