Class Mongo::PoolManager
In: lib/mongo/util/pool_manager.rb
Parent: Object

Methods

Attributes

arbiters  [R] 
connection  [R] 
hosts  [R] 
max_bson_size  [R] 
members  [R] 
nodes  [R] 
primary  [R] 
primary_pool  [R] 
read_pool  [R] 
secondaries  [R] 
secondary_pools  [R] 
tag_map  [R] 
tags_to_pools  [R] 

Public Class methods

Create a new set of connection pools.

The pool manager will by default use the original seed list passed to the connection objects, accessible via connection.seeds. In addition, the user may pass an additional list of seeds nodes discovered in real time. The union of these lists will be used when attempting to connect, with the newly-discovered nodes being used first.

[Source]

# File lib/mongo/util/pool_manager.rb, line 15
    def initialize(connection, seeds=[])
      @connection = connection
      @original_seeds = connection.seeds
      @seeds = seeds
      @previously_connected = false
    end

Public Instance methods

We‘re healthy if all members are pingable and if the view of the replica set returned by isMaster is equivalent to our view. If any of these isn‘t the case, set @refresh_required to true, and return.

[Source]

# File lib/mongo/util/pool_manager.rb, line 44
    def check_connection_health
      begin
        seed = get_valid_seed_node
      rescue ConnectionFailure
        @refresh_required = true
        return
      end

      config = seed.set_config
      if !config
        @refresh_required = true
        seed.close
        return
      end

      if config['hosts'].length != @members.length
        @refresh_required = true
        seed.close
        return
      end

      config['hosts'].each do |host|
        member = @members.detect do |m|
          m.address == host
        end

        if member && validate_existing_member(member)
          next
        else
          @refresh_required = true
          seed.close
          return false
        end
      end

      seed.close
    end

[Source]

# File lib/mongo/util/pool_manager.rb, line 87
    def close(opts={})
      begin
        if @primary_pool
          @primary_pool.close(opts)
        end

        if @secondary_pools
          @secondary_pools.each do |pool|
            pool.close(opts)
          end
        end

        if @members
          @members.each do |member|
            member.close
          end
        end

        rescue ConnectionFailure
      end
    end

[Source]

# File lib/mongo/util/pool_manager.rb, line 26
    def connect
      close if @previously_connected

      initialize_data
      members = connect_to_members
      initialize_pools(members)
      cache_discovered_seeds(members)
      set_read_pool
      set_tag_mappings

      @members = members
      @previously_connected = true
    end

[Source]

# File lib/mongo/util/pool_manager.rb, line 22
    def inspect
      "<Mongo::PoolManager:0x#{self.object_id.to_s(16)} @seeds=#{@seeds}>"
    end

The replica set connection should initiate a full refresh.

[Source]

# File lib/mongo/util/pool_manager.rb, line 83
    def refresh_required?
      @refresh_required
    end

The set of nodes that this class has discovered and successfully connected to.

[Source]

# File lib/mongo/util/pool_manager.rb, line 111
    def seeds
      @seeds || []
    end

[Validate]