Class Beetle::RedisServerInfo
In: lib/beetle/redis_server_info.rb
Parent: Object

class used by the RedisConfigurationServer to hold information about the current state of the configured redis servers

Methods

Included Modules

Logging

Public Instance methods

determine a master if we have one master and all other servers are slaves

[Source]

    # File lib/beetle/redis_server_info.rb, line 50
50:     def auto_detect_master
51:       return nil unless master_and_slaves_reachable?
52:       masters.first
53:     end

fetches the server from the insatnces whith the given server string

[Source]

    # File lib/beetle/redis_server_info.rb, line 18
18:     def find(server)
19:       instances.find{|r| r.server == server}
20:     end

all configured redis servers

[Source]

    # File lib/beetle/redis_server_info.rb, line 13
13:     def instances
14:       @instances ||= @config.redis_servers.split(/ *, */).map{|s| Redis.from_server_string(s, @options)}
15:     end

subset of instances which are masters

[Source]

    # File lib/beetle/redis_server_info.rb, line 30
30:     def masters
31:       @server_info["master"]
32:     end

refresh connectivity/role information

[Source]

    # File lib/beetle/redis_server_info.rb, line 23
23:     def refresh
24:       logger.debug "Updating redis server info"
25:       reset
26:       instances.each {|r| @server_info[r.role] << r}
27:     end

subset of instances which are slaves

[Source]

    # File lib/beetle/redis_server_info.rb, line 35
35:     def slaves
36:       @server_info["slave"]
37:     end

subset of instances which are set up as slaves of the given master

[Source]

    # File lib/beetle/redis_server_info.rb, line 45
45:     def slaves_of(master)
46:       slaves.select{|r| r.slave_of?(master.host, master.port)}
47:     end

subset of instances which are not reachable

[Source]

    # File lib/beetle/redis_server_info.rb, line 40
40:     def unknowns
41:       @server_info["unknown"]
42:     end

[Validate]