Class: Mongo::Cluster::Topology::Unknown
- Inherits:
-
Object
- Object
- Mongo::Cluster::Topology::Unknown
- Includes:
- Loggable
- Defined in:
- lib/mongo/cluster/topology/unknown.rb
Overview
Defines behaviour for when a cluster is in an unknown state.
Constant Summary collapse
- NAME =
The display name for the topology.
'Unknown'.freeze
Constants included from Loggable
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Options The options.
Instance Method Summary collapse
-
#add_hosts?(description, servers) ⇒ true, false
Whether a server description’s hosts may be added to the cluster.
-
#display_name ⇒ String
Get the display name.
-
#elect_primary(description, servers) ⇒ Sharded, ReplicaSet
Elect a primary server within this topology.
-
#initialize(options, seeds = []) ⇒ Unknown
constructor
Initialize the topology with the options.
-
#remove_hosts?(description) ⇒ true, false
Whether a description can be used to remove hosts from the cluster.
-
#remove_server?(description, server) ⇒ true, false
Whether a specific server in the cluster can be removed, given a description.
-
#replica_set? ⇒ false
An unknown topology is not a replica set.
-
#replica_set_name ⇒ nil
Unknown topologies have no replica set name.
-
#servers(servers) ⇒ Object
Select appropriate servers for this topology.
-
#sharded? ⇒ false
An unknown topology is not sharded.
-
#single? ⇒ true
An unknown topology is not single.
-
#standalone_discovered ⇒ Topology::Unknown, Topology::Single
Notify the topology that a standalone was discovered.
-
#unknown? ⇒ true
An unknown topology is unknown.
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Constructor Details
#initialize(options, seeds = []) ⇒ Unknown
Initialize the topology with the options.
73 74 75 76 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 73 def initialize(, seeds = []) @options = @seeds = seeds end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns options The options.
31 32 33 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 31 def @options end |
Instance Method Details
#add_hosts?(description, servers) ⇒ true, false
Whether a server description’s hosts may be added to the cluster.
154 155 156 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 154 def add_hosts?(description, servers) !(description.unknown? || description.ghost?) end |
#display_name ⇒ String
Get the display name.
41 42 43 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 41 def display_name NAME end |
#elect_primary(description, servers) ⇒ Sharded, ReplicaSet
Elect a primary server within this topology.
56 57 58 59 60 61 62 63 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 56 def elect_primary(description, servers) if description.mongos? log_debug("Mongos #{description.address.to_s} discovered.") Sharded.new() else initialize_replica_set(description, servers) end end |
#remove_hosts?(description) ⇒ true, false
Whether a description can be used to remove hosts from the cluster.
168 169 170 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 168 def remove_hosts?(description) description.standalone? end |
#remove_server?(description, server) ⇒ true, false
Whether a specific server in the cluster can be removed, given a description.
183 184 185 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 183 def remove_server?(description, server) description.standalone? && description.is_server?(server) end |
#replica_set? ⇒ false
An unknown topology is not a replica set.
86 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 86 def replica_set?; false; end |
#replica_set_name ⇒ nil
Unknown topologies have no replica set name.
96 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 96 def replica_set_name; nil; end |
#servers(servers) ⇒ Object
Select appropriate servers for this topology.
109 110 111 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 109 def servers(servers) [] end |
#sharded? ⇒ false
An unknown topology is not sharded.
121 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 121 def sharded?; false; end |
#single? ⇒ true
An unknown topology is not single.
131 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 131 def single?; false; end |
#standalone_discovered ⇒ Topology::Unknown, Topology::Single
Notify the topology that a standalone was discovered.
196 197 198 199 200 201 202 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 196 def standalone_discovered if @seeds.size == 1 Single.new(, @seeds) else self end end |
#unknown? ⇒ true
An unknown topology is unknown.
141 |
# File 'lib/mongo/cluster/topology/unknown.rb', line 141 def unknown?; true; end |