lib/mongo/cluster.rb in mongo-2.7.2 vs lib/mongo/cluster.rb in mongo-2.8.0.rc0

- old
+ new

@@ -97,11 +97,10 @@ @event_listeners = Event::Listeners.new @options = options.freeze @app_metadata = Server::AppMetadata.new(@options) @update_lock = Mutex.new @sdam_flow_lock = Mutex.new - @pool_lock = Mutex.new @cluster_time = nil @cluster_time_lock = Mutex.new @topology = Topology.initial(self, monitoring, options) Session::SessionPool.create(self) @@ -151,11 +150,11 @@ @cursor_reaper = CursorReaper.new @socket_reaper = SocketReaper.new(self) @periodic_executor = PeriodicExecutor.new(@cursor_reaper, @socket_reaper) @periodic_executor.run! - ObjectSpace.define_finalizer(self, self.class.finalize(pools, @periodic_executor, @session_pool)) + ObjectSpace.define_finalizer(self, self.class.finalize({}, @periodic_executor, @session_pool)) @connecting = false @connected = true if options[:scan] != false @@ -339,32 +338,30 @@ "topology=#{topology.summary} "+ "servers=[#{servers_list.map(&:summary).join(',')}]>" end # @api private - attr_reader :server_selection_semaphore + def server_selection_semaphore + options[:server_selection_semaphore] + end - # Finalize the cluster for garbage collection. Disconnects all the scoped - # connection pools. + # Finalize the cluster for garbage collection. # # @example Finalize the cluster. # Cluster.finalize(pools) # - # @param [ Hash<Address, Server::ConnectionPool> ] pools The connection pools. + # @param [ Hash<Address, Server::ConnectionPool> ] pools Ignored. # @param [ PeriodicExecutor ] periodic_executor The periodic executor. # @param [ SessionPool ] session_pool The session pool. # # @return [ Proc ] The Finalizer. # # @since 2.2.0 def self.finalize(pools, periodic_executor, session_pool) proc do session_pool.end_sessions periodic_executor.stop! - pools.values.each do |pool| - pool.disconnect! - end end end # Disconnect all servers. # @@ -521,24 +518,23 @@ def next_primary(ping = true) @primary_selector ||= ServerSelector.get(ServerSelector::PRIMARY) @primary_selector.select_server(self) end - # Get the scoped connection pool for the server. + # Get the connection pool for the server. # # @example Get the connection pool. # cluster.pool(server) # # @param [ Server ] server The server. # # @return [ Server::ConnectionPool ] The connection pool. # # @since 2.2.0 + # @deprecated def pool(server) - @pool_lock.synchronize do - pools[server.address] ||= Server::ConnectionPool.get(server) - end + server.pool end # Update the max cluster time seen in a response. # # @example Update the cluster time. @@ -672,13 +668,9 @@ ServerSelector.get(mode: :primary_preferred).select_server(self) !!topology.logical_session_timeout rescue Error::NoServerAvailable false end - end - - def pools - @pools ||= {} end end end require 'mongo/cluster/sdam_flow'