lib/mongo/cluster.rb
def run_sdam_flow(previous_desc, updated_desc, options = {})
      if load_balanced?
        if updated_desc.config.empty?
          unless options[:keep_connection_pool]
            servers_list.each do |server|
              # TODO should service id be taken out of updated_desc?
              # We could also assert that
              # options[:service_id] == updated_desc.service_id
              server.clear_connection_pool(service_id: options[:service_id])
            end
          end
        end
        return
      end

      @sdam_flow_lock.synchronize do
        flow = SdamFlow.new(self, previous_desc, updated_desc,
          awaited: options[:awaited])
        flow.server_description_changed

        # SDAM flow may alter the updated description - grab the final
        # version for the purposes of broadcasting if a server is available
        updated_desc = flow.updated_desc

        unless options[:keep_connection_pool]
          if flow.became_unknown?
            servers_list.each do |server|
              if server.address == updated_desc.address
                server.clear_connection_pool
              end
            end
          end
        end

        start_stop_srv_monitor
      end

      # Some updated descriptions, e.g. a mismatched me one, result in the
      # server whose description we are processing being removed from
      # the topology. When this happens, the server's monitoring thread gets
      # killed. As a result, any code after the flow invocation may not run
      # a particular monitor instance, hence there should generally not be
      # any code in this method past the flow invocation.
      #
      # However, this broadcast call can be here because if the monitoring
      # thread got killed the server should have been closed and no client
      # should be currently waiting for it, thus not signaling the semaphore
      # shouldn't cause any problems.
      unless updated_desc.unknown?
        server_selection_semaphore.broadcast
      end
    end
# Runs SDAM flow on the cluster.
#
# This method can be invoked to process a new server description returned
# by the server on a monitoring or non-monitoring connection, and also
# by the driver when it marks a server unknown as a result of a (network)
# error.
#
# @param [ Server::Description ] previous_desc Previous server description.
# @param [ Server::Description ] updated_desc The changed description.
# @param [ Hash ] options Options.
#
# @option options [ true | false ] :keep_connection_pool Usually when the
#   new server description is unknown, the connection pool on the
#   respective server is cleared. Set this option to true to keep the
#   existing connection pool (required when handling not master errors
#   on 4.2+ servers).
# @option aptions [ true | false ] :awaited Whether the updated description
#   was a result of processing an awaited hello.
# @option options [ Object ] :service_id Change state for the specified
#   service id only.
#
# @api private
Runs SDAM flow on the cluster.
This method can be invoked to process a new server description returned
by the server on a monitoring or non-monitoring connection, and also
by the driver when it marks a server unknown as a result of a (network)
error.
Runs SDAM flow on the cluster . This method can be invoked to process a new server description returned by the server on a monitoring or non - monitoring connection and also by the driver when it marks a server unknown as a result of a ( network ) error .
def run_sdam_flow(previous_desc, updated_desc, options = {})
      if load_balanced?
        if updated_desc.config.empty?
          unless options[:keep_connection_pool]
            servers_list.each do |server|
              server.clear_connection_pool(service_id: options[:service_id])
            end
          end
        end
        return
      end
      @sdam_flow_lock.synchronize do
        flow = SdamFlow.new(self, previous_desc, updated_desc,
          awaited: options[:awaited])
        flow.server_description_changed
        updated_desc = flow.updated_desc
        unless options[:keep_connection_pool]
          if flow.became_unknown?
            servers_list.each do |server|
              if server.address == updated_desc.address
                server.clear_connection_pool
              end
            end
          end
        end
        start_stop_srv_monitor
      end
       However, this broadcast call can be here because if the monitoring
       thread got killed the server should have been closed and no client
       should be currently waiting for it, thus not signaling the semaphore
       shouldn't cause any problems.
      unless updated_desc.unknown?
        server_selection_semaphore.broadcast
      end
    end
def run_sdam_flow ( previous_desc , updated_desc , options = { } ) if load_balanced? if updated_desc . config . empty? unless options [ :keep_connection_pool ] servers_list . each do | server | server . clear_connection_pool ( service_id : options [ :service_id ] ) end end end return end @sdam_flow_lock . synchronize do flow = SdamFlow . new ( self , previous_desc , updated_desc , awaited : options [ :awaited ] ) flow . server_description_changed updated_desc = flow . updated_desc unless options [ :keep_connection_pool ] if flow . became_unknown? servers_list . each do | server | if server . address == updated_desc . address server . clear_connection_pool end end end end start_stop_srv_monitor end unless updated_desc . unknown? server_selection_semaphore . broadcast end end
Runs SDAM flow on the cluster.
Runs SDAM flow on the cluster .
# TODO should service id be taken out of updated_desc? # We could also assert that # options[:service_id] == updated_desc.service_id # SDAM flow may alter the updated description - grab the final # version for the purposes of broadcasting if a server is available # Some updated descriptions, e.g. a mismatched me one, result in the # server whose description we are processing being removed from # the topology. When this happens, the server's monitoring thread gets # killed. As a result, any code after the flow invocation may not run # a particular monitor instance, hence there should generally not be # any code in this method past the flow invocation. # # However, this broadcast call can be here because if the monitoring # thread got killed the server should have been closed and no client # should be currently waiting for it, thus not signaling the semaphore # shouldn't cause any problems.
previous_desc
updated_desc
options
:service_id Change state for the specified service id only.
: service_id Change state for the specified service id only .
None
aptions
:awaited Whether the updated description was a result of processing an awaited hello.
: awaited Whether the updated description was a result of processing an awaited hello .
api
None