lib/topologies/mongos.js
function pingServer(_self, _server, cb) {
      // Measure running time
      var start = new Date().getTime();

      // Emit the server heartbeat start
      emitSDAMEvent(self, 'serverHeartbeatStarted', { connectionId: _server.name });

      // Execute ismaster
      _server.command(
        'admin.$cmd',
        {
          ismaster: true
        },
        {
          monitoring: true,
          socketTimeout: self.s.options.connectionTimeout || 2000
        },
        function(err, r) {
          if (self.state === DESTROYED || self.state === UNREFERENCED) {
            // Move from connectingProxies
            moveServerFrom(self.connectedProxies, self.disconnectedProxies, _server);
            _server.destroy();
            return cb(err, r);
          }

          // Calculate latency
          var latencyMS = new Date().getTime() - start;

          // We had an error, remove it from the state
          if (err) {
            // Emit the server heartbeat failure
            emitSDAMEvent(self, 'serverHeartbeatFailed', {
              durationMS: latencyMS,
              failure: err,
              connectionId: _server.name
            });
            // Move from connected proxies to disconnected proxies
            moveServerFrom(self.connectedProxies, self.disconnectedProxies, _server);
          } else {
            // Update the server ismaster
            _server.ismaster = r.result;
            _server.lastIsMasterMS = latencyMS;

            // Server heart beat event
            emitSDAMEvent(self, 'serverHeartbeatSucceeded', {
              durationMS: latencyMS,
              reply: r.result,
              connectionId: _server.name
            });
          }

          cb(err, r);
        }
      );
    }
function pingServer(_self, _server, cb) {
      // Measure running time
      var start = new Date().getTime();

      // Emit the server heartbeat start
      emitSDAMEvent(self, 'serverHeartbeatStarted', { connectionId: _server.name });

      // Execute ismaster
      _server.command(
        'admin.$cmd',
        {
          ismaster: true
        },
        {
          monitoring: true,
          socketTimeout: self.s.options.connectionTimeout || 2000
        },
        function(err, r) {
          if (self.state === DESTROYED || self.state === UNREFERENCED) {
            // Move from connectingProxies
            moveServerFrom(self.connectedProxies, self.disconnectedProxies, _server);
            _server.destroy();
            return cb(err, r);
          }

          // Calculate latency
          var latencyMS = new Date().getTime() - start;

          // We had an error, remove it from the state
          if (err) {
            // Emit the server heartbeat failure
            emitSDAMEvent(self, 'serverHeartbeatFailed', {
              durationMS: latencyMS,
              failure: err,
              connectionId: _server.name
            });
            // Move from connected proxies to disconnected proxies
            moveServerFrom(self.connectedProxies, self.disconnectedProxies, _server);
          } else {
            // Update the server ismaster
            _server.ismaster = r.result;
            _server.lastIsMasterMS = latencyMS;

            // Server heart beat event
            emitSDAMEvent(self, 'serverHeartbeatSucceeded', {
              durationMS: latencyMS,
              reply: r.result,
              connectionId: _server.name
            });
          }

          cb(err, r);
        }
      );
    }
function pingServer ( _self , _server , cb ) { // Measure running time var start = new Date ( ) . getTime ( ) ; // Emit the server heartbeat start emitSDAMEvent ( self , 'serverHeartbeatStarted' , { connectionId : _server . name } ) ; // Execute ismaster _server . command ( 'admin.$cmd' , { ismaster : true } , { monitoring : true , socketTimeout : self . s . options . connectionTimeout || 2000 } , function ( err , r ) { if ( self . state === DESTROYED || self . state === UNREFERENCED ) { // Move from connectingProxies moveServerFrom ( self . connectedProxies , self . disconnectedProxies , _server ) ; _server . destroy ( ) ; return cb ( err , r ) ; } // Calculate latency var latencyMS = new Date ( ) . getTime ( ) - start ; // We had an error, remove it from the state if ( err ) { // Emit the server heartbeat failure emitSDAMEvent ( self , 'serverHeartbeatFailed' , { durationMS : latencyMS , failure : err , connectionId : _server . name } ) ; // Move from connected proxies to disconnected proxies moveServerFrom ( self . connectedProxies , self . disconnectedProxies , _server ) ; } else { // Update the server ismaster _server . ismaster = r . result ; _server . lastIsMasterMS = latencyMS ; // Server heart beat event emitSDAMEvent ( self , 'serverHeartbeatSucceeded' , { durationMS : latencyMS , reply : r . result , connectionId : _server . name } ) ; } cb ( err , r ) ; } ) ; }
If the count is zero schedule a new fast
If the count is zero schedule a new fast