private void CreateActualProxy(MongoServerInstance instance, BlockingQueue <MongoServerInstance> connectionQueue) { lock (_lock) { if (instance.InstanceType == MongoServerInstanceType.ReplicaSetMember) { _serverProxy = new ReplicaSetMongoServerProxy(_settings, _instances, connectionQueue, _connectionAttempt); } else if (instance.InstanceType == MongoServerInstanceType.ShardRouter) { _serverProxy = new ShardedMongoServerProxy(_settings, _instances, connectionQueue, _connectionAttempt); } else if (instance.InstanceType == MongoServerInstanceType.StandAlone) { var otherInstances = _instances.Where(x => x != instance).ToList(); foreach (var otherInstance in otherInstances) { otherInstance.Disconnect(); } _serverProxy = new DirectMongoServerProxy(_settings, instance, _connectionAttempt); } else { throw new MongoConnectionException("The type of servers in the host list could not be determined."); } } }
// constructors /// <summary> /// Creates a new instance of MongoServer. Normally you will use one of the Create methods instead /// of the constructor to create instances of this class. /// </summary> /// <param name="settings">The settings for this instance of MongoServer.</param> public MongoServer(MongoServerSettings settings) { _settings = settings.FrozenCopy(); _sequentialId = Interlocked.Increment(ref __nextSequentialId); // Console.WriteLine("MongoServer[{0}]: {1}", sequentialId, settings); _serverProxy = new MongoServerProxyFactory().Create(_settings); }
private void CreateActualProxy(MongoServerInstance instance, BlockingQueue<MongoServerInstance> connectionQueue) { lock (_lock) { if (instance.InstanceType == MongoServerInstanceType.ReplicaSetMember) { _serverProxy = new ReplicaSetMongoServerProxy(_settings, _instances, connectionQueue, _connectionAttempt); } else if (instance.InstanceType == MongoServerInstanceType.ShardRouter) { _serverProxy = new ShardedMongoServerProxy(_settings, _instances, connectionQueue, _connectionAttempt); } else if (instance.InstanceType == MongoServerInstanceType.StandAlone) { var otherInstances = _instances.Where(x => x != instance).ToList(); foreach (var otherInstance in otherInstances) { otherInstance.Disconnect(); } _serverProxy = new DirectMongoServerProxy(_settings, instance, _connectionAttempt); } else { throw new MongoConnectionException("The type of servers in the host list could not be determined."); } } }