Module: Mongo::ShardingNode

Defined in:
lib/mongo/util/sharding_pool_manager.rb

Instance Method Summary collapse

Instance Method Details

#node_listObject

Return a list of sharded cluster nodes from the config - currently just the current node.



29
30
31
32
33
34
35
36
# File 'lib/mongo/util/sharding_pool_manager.rb', line 29

def node_list
  connect unless connected?
  set_config unless @config

  return [] unless config

  ["#{@host}:#{@port}"]
end

#set_configObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mongo/util/sharding_pool_manager.rb', line 4

def set_config
  begin
    @config = @client['admin'].command({:ismaster => 1}, :socket => @socket)

    # warning: instance variable @logger not initialized
    #if @config['msg'] && @logger
    #  @client.log(:warn, "#{config['msg']}")
    #end

  rescue ConnectionFailure, OperationFailure, OperationTimeout, SocketError, SystemCallError, IOError => ex
    @client.log(:warn, "Attempted connection to node #{host_string} raised " +
        "#{ex.class}: #{ex.message}")

    # Socket may already be nil from issuing command
    if @socket && !@socket.closed?
      @socket.close
    end

    return nil
  end

  @config
end