Comparing version 1.3.4 to 1.3.5
@@ -247,3 +247,4 @@ var utils = require('./connection_utils'), | ||
ConnectionPool.prototype.isConnected = function() { | ||
return this._poolState === 'connected'; | ||
// return this._poolState === 'connected'; | ||
return this.openConnections.length > 0 && this.openConnections[0].isConnected(); | ||
} | ||
@@ -250,0 +251,0 @@ |
@@ -9,2 +9,3 @@ var DbCommand = require('../../commands/db_command').DbCommand | ||
this.state = HighAvailabilityProcess.INIT; | ||
this.selectedIndex = 0; | ||
} | ||
@@ -29,2 +30,3 @@ | ||
this.state = HighAvailabilityProcess.RUNNING; | ||
// Get all possible reader servers | ||
@@ -36,22 +38,9 @@ var candidate_servers = this.replset._state.getAllReadServers(); | ||
// var server = candidate_servers.pop(); | ||
var server = null; | ||
// Locate a server that is connected and use that for HA | ||
for(var i = 0; i < candidate_servers.length; i++) { | ||
if(candidate_servers[i].isConnected()) { | ||
server = candidate_servers[i]; | ||
break; | ||
} | ||
} | ||
// No server connected let's pick one randomly and try to connect | ||
if(server == null) { | ||
server = candidate_servers[Math.round(Math.random(1000000) * (candidate_servers.length - 1))]; | ||
} | ||
// Select a candidate server for the connection | ||
var server = candidate_servers[this.selectedIndex % candidate_servers.length]; | ||
this.selectedIndex = this.selectedIndex + 1; | ||
// Unpack connection options | ||
var connectTimeoutMS = self.options.connectTimeoutMS || 30000; | ||
// var socketTimeoutMS = self.options.socketTimeoutMS || 30000; | ||
var socketTimeoutMS = 30000; | ||
var connectTimeoutMS = self.options.connectTimeoutMS || 10000; | ||
var socketTimeoutMS = self.options.socketTimeoutMS || 30000; | ||
@@ -141,3 +130,2 @@ // Just ensure we don't have a full cycle dependency | ||
, function(err, res) { | ||
if(err) { | ||
@@ -216,4 +204,5 @@ self.server.close(); | ||
// Unpack connection options | ||
var connectTimeoutMS = self.options.connectTimeoutMS || 30000; | ||
var connectTimeoutMS = self.options.connectTimeoutMS || 10000; | ||
var socketTimeoutMS = self.options.socketTimeoutMS || 30000; | ||
// Server class | ||
@@ -220,0 +209,0 @@ var Db = require('../../db').Db |
@@ -208,3 +208,3 @@ var Connection = require('./connection').Connection, | ||
Server.prototype.isConnected = function() { | ||
return this._serverState == 'connected'; | ||
return this.connectionPool.isConnected(); | ||
} | ||
@@ -211,0 +211,0 @@ |
{ "name" : "mongodb" | ||
, "description" : "A node.js driver for MongoDB" | ||
, "keywords" : ["mongodb", "mongo", "driver", "db"] | ||
, "version" : "1.3.4" | ||
, "version" : "1.3.5" | ||
, "author" : "Christian Amor Kvalheim <christkv@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "contributors" : [ "Aaron Heckmann", |
540226
12425