lib/mongo/cluster/sdam_flow.rb
def commit_changes
      # The application-visible sequence of events should be as follows:
      #
      # 1. Description change for the server which we are processing;
      # 2. Topology change, if any;
      # 3. Description changes for other servers, if any.
      #
      # The tricky part here is that the server description changes are
      # not all processed together.

      publish_description_change_event
      start_pool_if_data_bearing

      topology_changed_event_published = false
      if topology.object_id != cluster.topology.object_id || @need_topology_changed_event
        # We are about to publish topology changed event.
        # Recreate the topology instance to get its server descriptions
        # up to date.
        @topology = topology.class.new(topology.options, topology.monitoring, cluster)
        # This sends the SDAM event
        cluster.update_topology(topology)
        topology_changed_event_published = true
        @need_topology_changed_event = false
      end

      # If a server description changed, topology description change event
      # must be published with the previous and next topologies being of
      # the same type, unless we already published topology change event
      if topology_changed_event_published
        return
      end

      if updated_desc.unknown? && previous_desc.unknown?
        return
      end
      if updated_desc.object_id == previous_desc.object_id
        return
      end

      # If we are here, there has been a change in the server descriptions
      # in our topology, but topology class has not changed.
      # Publish the topology changed event and recreate the topology to
      # get the new list of server descriptions into it.
      @topology = topology.class.new(topology.options, topology.monitoring, cluster)
      # This sends the SDAM event
      cluster.update_topology(topology)
    end
# Publishes server description changed events, updates topology on
# the cluster and publishes topology changed event, as needed
# based on operations performed during SDAM flow processing.
Publishes server description changed events, updates topology on
the cluster and publishes topology changed event, as needed
based on operations performed during SDAM flow processing.
Publishes server description changed events updates topology on the cluster and publishes topology changed event as needed based on operations performed during SDAM flow processing .
def commit_changes
       1. Description change for the server which we are processing;
       2. Topology change, if any;
       3. Description changes for other servers, if any.
       The tricky part here is that the server description changes are
       not all processed together.
      publish_description_change_event
      start_pool_if_data_bearing
      topology_changed_event_published = false
      if topology.object_id != cluster.topology.object_id || @need_topology_changed_event
         We are about to publish topology changed event.
         Recreate the topology instance to get its server descriptions
         up to date.
        @topology = topology.class.new(topology.options, topology.monitoring, cluster)
         This sends the SDAM event
        cluster.update_topology(topology)
        topology_changed_event_published = true
        @need_topology_changed_event = false
      end
       If a server description changed, topology description change event
       must be published with the previous and next topologies being of
       the same type, unless we already published topology change event
      if topology_changed_event_published
        return
      end
      if updated_desc.unknown? && previous_desc.unknown?
        return
      end
      if updated_desc.object_id == previous_desc.object_id
        return
      end
       If we are here, there has been a change in the server descriptions
       in our topology, but topology class has not changed.
       Publish the topology changed event and recreate the topology to
       get the new list of server descriptions into it.
      @topology = topology.class.new(topology.options, topology.monitoring, cluster)
       This sends the SDAM event
      cluster.update_topology(topology)
    end
def commit_changes publish_description_change_event start_pool_if_data_bearing topology_changed_event_published = false if topology . object_id != cluster . topology . object_id || @need_topology_changed_event @topology = topology . class . new ( topology . options , topology . monitoring , cluster ) cluster . update_topology ( topology ) topology_changed_event_published = true @need_topology_changed_event = false end if topology_changed_event_published return end if updated_desc . unknown? && previous_desc . unknown? return end if updated_desc . object_id == previous_desc . object_id return end @topology = topology . class . new ( topology . options , topology . monitoring , cluster ) cluster . update_topology ( topology ) end
Publishes server description changed events, updates topology on
the cluster and publishes topology changed event, as needed
based on operations performed during SDAM flow processing.
Publishes server description changed events updates topology on the cluster and publishes topology changed event as needed based on operations performed during SDAM flow processing .
# The application-visible sequence of events should be as follows: # # 1. Description change for the server which we are processing; # 2. Topology change, if any; # 3. Description changes for other servers, if any. # # The tricky part here is that the server description changes are # not all processed together. # We are about to publish topology changed event. # Recreate the topology instance to get its server descriptions # up to date. # This sends the SDAM event # If a server description changed, topology description change event # must be published with the previous and next topologies being of # the same type, unless we already published topology change event # If we are here, there has been a change in the server descriptions # in our topology, but topology class has not changed. # Publish the topology changed event and recreate the topology to # get the new list of server descriptions into it. # This sends the SDAM event