Skip to content

Commit

Permalink
Cleanup of debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Apr 23, 2013
1 parent 99aeb61 commit 0d4be8d
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 51 deletions.
1 change: 0 additions & 1 deletion lib/mongodb/commands/db_command.js
Expand Up @@ -208,7 +208,6 @@ DbCommand.createCreateIndexCommand = function(db, collectionName, fieldOrSpec, o

DbCommand.logoutCommand = function(db, command_hash, options) {
var dbName = options != null && options['authdb'] != null ? options['authdb'] : db.databaseName;
// Create logout command
return new DbCommand(db, dbName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, command_hash, null);
}

Expand Down
5 changes: 1 addition & 4 deletions lib/mongodb/connection/base.js
Expand Up @@ -75,13 +75,10 @@ NonExecutedOperationStore.prototype.execute_writes = function() {
while(this.commands.write.length > 0) {
// Get the next command
var command = this.commands.write.shift();
// // Remove any connection
// if(command['options'] == null) command['options'] = {};
// command['options'].connection = this.config.checkoutWriter();
// Set the connection
command.options.connection = connection;
// Execute the next command
command.executeInsertCommand(command.db, command.db_command, command.options, command.callback);
// write_func(db, command['db_command'], command['options'], command['callback']);
}
}

Expand Down
21 changes: 0 additions & 21 deletions lib/mongodb/connection/mongos.js
Expand Up @@ -120,11 +120,6 @@ Mongos.prototype.connect = function(db, options, callback) {
// Error handler
var errorOrCloseHandler = function(_server) {
return function(err, result) {
// console.log("================================ errorOrCloseHandler :: " + _server.port)
// for(var i = 0; i < self.servers.length;i++) {
// console.log(" errorOrCloseHandler :: - " + self.servers[i].port)
// }

var validServers = [];
// Execute all the callbacks with errors
self.__executeAllCallbacksWithError(err);
Expand All @@ -151,16 +146,12 @@ Mongos.prototype.connect = function(db, options, callback) {

// Set current list of servers
self.servers = validServers;
// for(var i = 0; i < self.servers.length;i++) {
// console.log(" AFTER errorOrCloseHandler :: - " + self.servers[i].port)
// }
}
}

// Mongo function
this.mongosCheckFunction = function() {
if(self._haInProgress) return;
// console.log("=================================== MONGOS PING")
// Set as not waiting for check event
self._haInProgress = true;
// Check downed servers
Expand Down Expand Up @@ -189,16 +180,9 @@ Mongos.prototype.connect = function(db, options, callback) {
// Setup the connection function
var connectFunction = function(_db, _server, _options, _callback) {
return function() {
// console.log("======================================= connect with options")
// console.dir(_options)
// Attempt to connect
_server.connect(_db, _options, function(err, result, _server2) {
numberOfServersLeft = numberOfServersLeft - 1;
// console.log("=================================== MONGOS PING CONNECT")
// console.dir(err)
// console.dir(result)
// console.dir(_server2)
// console.dir(_server.isMasterDoc)

if(err) {
return _callback(err, _server);
Expand Down Expand Up @@ -408,10 +392,6 @@ Mongos.prototype.isDestroyed = function() {
* @ignore
*/
Mongos.prototype.checkoutWriter = function() {
// console.log("======================== MONGOS :: checkout writer :: " + this.servers.length)
// for(var i = 0; i < this.servers.length;i++) {
// console.log(" MONGOS :: checkout writer - " + this.servers[i].port)
// }
if(this.servers.length == 0) return null;
return this.servers[0].checkoutWriter();
}
Expand All @@ -420,7 +400,6 @@ Mongos.prototype.checkoutWriter = function() {
* @ignore
*/
Mongos.prototype.checkoutReader = function(read) {
// console.log("======================== MONGOS :: checkout reader")
// If we have a read preference object unpack it
if(typeof read == 'object' && read['_type'] == 'ReadPreference') {
// Validate if the object is using a valid mode
Expand Down
4 changes: 0 additions & 4 deletions lib/mongodb/connection/repl_set/ha.js
Expand Up @@ -13,7 +13,6 @@ HighAvailabilityProcess.RUNNING = 'running';
HighAvailabilityProcess.STOPPED = 'stopped';

HighAvailabilityProcess.prototype.start = function() {
// console.log("===================== START HA Process")
if(this.replset._state
&& Object.keys(this.replset._state.addresses).length == 0) {
if(this.server) this.server.close();
Expand Down Expand Up @@ -123,7 +122,6 @@ var _timeoutHandle = function(self) {

// If the server is connected
if(self.server.isConnected() && !self._haProcessInProcess) {
// console.log("===================== HA Process")
// Start HA process
self._haProcessInProcess = true;
// Execute is master command
Expand Down Expand Up @@ -198,7 +196,6 @@ var _timeoutHandle = function(self) {
}

var _reconnect_servers = function(self, reconnect_servers) {
// console.log("============================== _reconnect_servers")
if(reconnect_servers.length == 0) {
self._haProcessInProcess = false
return setTimeout(_timeoutHandle(self), self.options.haInterval);
Expand Down Expand Up @@ -250,7 +247,6 @@ var _reconnect_servers = function(self, reconnect_servers) {

// Let's attempt a connection over here
newServer.connect(db, function(err, result, _server) {
// console.log("============================== _reconnect_servers 1")
if(self.state == HighAvailabilityProcess.STOPPED) {
_server.close();
}
Expand Down
6 changes: 1 addition & 5 deletions lib/mongodb/connection/repl_set/repl_set.js
Expand Up @@ -195,7 +195,7 @@ ReplSet.prototype.connect = function(parent, options, callback) {

// If we have a strategy defined start it
if(self.strategyInstance) {
// self.strategyInstance.start();
self.strategyInstance.start();
}

// Finishing up the call
Expand Down Expand Up @@ -293,7 +293,6 @@ var createServer = function(self, host, options) {

var _handler = function(event, self, server) {
return function(err, doc) {
// console.log("=============================================== _handler :: " + event)
// The event happened to a primary
// Remove it from play
if(self._state.isPrimary(server)) {
Expand Down Expand Up @@ -442,7 +441,6 @@ ReplSet.prototype.isMongos = function() {
}

ReplSet.prototype.checkoutWriter = function() {
// console.log("========================= checkoutWriter")
if(this._state.master) return this._state.master.checkoutWriter();
return new Error("no writer connection available");
}
Expand Down Expand Up @@ -483,8 +481,6 @@ ReplSet.prototype.allServerInstances = function() {
* @ignore
*/
ReplSet.prototype.checkoutReader = function(readPreference, tags) {
// console.log("========================= checkoutReader")
// console.dir(readPreference)
var connection = null;

// If we have a read preference object unpack it
Expand Down
16 changes: 0 additions & 16 deletions lib/mongodb/db.js
Expand Up @@ -597,14 +597,11 @@ Db.prototype.logout = function(options, callback) {
// Number of connections we need to logout from
var numberOfConnections = this.serverConfig.allRawConnections().length;

// console.log("========================================== logout")

// Let's generate the logout command object
var logoutCommand = DbCommand.logoutCommand(self, {logout:1}, options);
self._executeQueryCommand(logoutCommand, {onAll:true}, function(err, result) {
// Count down
numberOfConnections = numberOfConnections - 1;
// console.log("========================================== logout 1 :: " + numberOfConnections)
// Work around the case where the number of connections are 0
if(numberOfConnections <= 0 && typeof callback == 'function') {
var internalCallback = callback;
Expand Down Expand Up @@ -1577,16 +1574,10 @@ Db.prototype._executeQueryCommand = function(db_command, options, callback) {
var config = this.serverConfig;
var read = options.read;

// console.log("================================================ _executeQueryCommand")
// console.log("canRead = " + config.canRead(read))
// console.log("canWrite = " + config.canWrite())
// console.log("isAutoReconnect = " + config.isAutoReconnect())

if(!config.canRead(read) && !config.canWrite() && config.isAutoReconnect()) {
if(read == ReadPreference.PRIMARY
|| read == ReadPreference.PRIMARY_PREFERRED
|| read == null) {
// console.log("= _executeQueryCommand :: 0")

// Save the command
self.serverConfig._commandsStore.read_from_writer(
Expand All @@ -1600,8 +1591,6 @@ Db.prototype._executeQueryCommand = function(db_command, options, callback) {
}
);
} else {
// console.log("= _executeQueryCommand :: 1")

self.serverConfig._commandsStore.read(
{ type: 'query'
, db_command: db_command
Expand All @@ -1614,10 +1603,8 @@ Db.prototype._executeQueryCommand = function(db_command, options, callback) {
);
}
} else if(!config.canRead(read) && !config.canWrite() && !config.isAutoReconnect()) {
// console.log("= _executeQueryCommand :: 2")
return callback(new Error("no open connections"), null);
} else {
// console.log("= _executeQueryCommand :: 3")
// Execute the command
__executeQueryCommand(self, db_command, options, function (err, result, conn) {
if(callback) callback(err, result, conn);
Expand Down Expand Up @@ -1712,7 +1699,6 @@ Db.prototype._executeInsertCommand = function(db_command, options, callback) {
var config = self.serverConfig;
// Check if we are connected
if(!config.canWrite() && config.isAutoReconnect()) {
// console.log("============================ _executeInsertCommand :: 0")
processor(function() {
self.serverConfig._commandsStore.write(
{ type:'insert'
Expand All @@ -1726,10 +1712,8 @@ Db.prototype._executeInsertCommand = function(db_command, options, callback) {
);
})
} else if(!config.canWrite() && !config.isAutoReconnect()) {
// console.log("============================ _executeInsertCommand :: 1")
return callback(new Error("no open connections"), null);
} else {
// console.log("============================ _executeInsertCommand :: 2")
// Execute write command
__executeInsertCommand(self, db_command, options, callback);
}
Expand Down

0 comments on commit 0d4be8d

Please sign in to comment.