Class: Mongo::Cluster::Topology::Sharded
- Inherits:
-
Object
- Object
- Mongo::Cluster::Topology::Sharded
- Includes:
- Monitoring::Publishable
- Defined in:
- lib/mongo/cluster/topology/sharded.rb
Overview
Defines behaviour for when a cluster is in sharded topology.
Constant Summary collapse
- NAME =
The display name for the topology.
'Sharded'.freeze
Instance Attribute Summary collapse
-
#monitoring ⇒ Monitoring
readonly
Monitoring The monitoring.
-
#options ⇒ Hash
readonly
Options The options.
Instance Method Summary collapse
-
#add_hosts?(description, servers) ⇒ 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
Elect a primary server within this topology.
-
#has_readable_server?(cluster, server_selector = nil) ⇒ true
Determine if the topology would select a readable server for the provided candidates and read preference.
-
#has_writable_server?(cluster) ⇒ true
Determine if the topology would select a writable server for the provided candidates.
-
#initialize(options, monitoring, seeds = []) ⇒ Sharded
constructor
Initialize the topology with the options.
-
#member_discovered ⇒ Object
Notify the topology that a member was discovered.
-
#remove_hosts?(description) ⇒ true
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
A sharded topology is not a replica set.
-
#replica_set_name ⇒ nil
Sharded topologies have no replica set name.
-
#servers(servers) ⇒ Array<Server>
Select appropriate servers for this topology.
-
#sharded? ⇒ true
A sharded topology is sharded.
-
#single? ⇒ false
A sharded topology is not single.
-
#standalone_discovered ⇒ Topology::Sharded
Notify the topology that a standalone was discovered.
-
#unknown? ⇒ false
A sharded topology is not unknown.
Methods included from Monitoring::Publishable
#publish_command, #publish_event, #publish_sdam_event
Constructor Details
#initialize(options, monitoring, seeds = []) ⇒ Sharded
Initialize the topology with the options.
99 100 101 102 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 99 def initialize(, monitoring, seeds = []) @options = @monitoring = monitoring end |
Instance Attribute Details
#monitoring ⇒ Monitoring (readonly)
Returns monitoring The monitoring.
34 35 36 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 34 def monitoring @monitoring end |
#options ⇒ Hash (readonly)
Returns options The options.
31 32 33 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 31 def @options end |
Instance Method Details
#add_hosts?(description, servers) ⇒ false
Whether a server description’s hosts may be added to the cluster.
150 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 150 def add_hosts?(description, servers); false; end |
#display_name ⇒ String
Get the display name.
44 45 46 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 44 def display_name NAME end |
#elect_primary(description, servers) ⇒ Sharded
Elect a primary server within this topology.
59 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 59 def elect_primary(description, servers); self; end |
#has_readable_server?(cluster, server_selector = nil) ⇒ true
Determine if the topology would select a readable server for the provided candidates and read preference.
74 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 74 def has_readable_server?(cluster, server_selector = nil); true; end |
#has_writable_server?(cluster) ⇒ true
Determine if the topology would select a writable server for the provided candidates.
87 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 87 def has_writable_server?(cluster); true; end |
#member_discovered ⇒ Object
Notify the topology that a member was discovered.
228 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 228 def member_discovered; end |
#remove_hosts?(description) ⇒ true
Whether a description can be used to remove hosts from the cluster.
the cluster.
topology.remove_hosts?(description)
164 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 164 def remove_hosts?(description); true; end |
#remove_server?(description, server) ⇒ true, false
Whether a specific server in the cluster can be removed, given a description.
177 178 179 180 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 177 def remove_server?(description, server) remove_self?(description, server) || !(server.mongos? || server.unknown?) end |
#replica_set? ⇒ false
A sharded topology is not a replica set.
112 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 112 def replica_set?; false; end |
#replica_set_name ⇒ nil
Sharded topologies have no replica set name.
122 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 122 def replica_set_name; nil; end |
#servers(servers) ⇒ Array<Server>
Select appropriate servers for this topology.
134 135 136 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 134 def servers(servers) servers.select{ |server| server.mongos? } end |
#sharded? ⇒ true
A sharded topology is sharded.
190 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 190 def sharded?; true; end |
#single? ⇒ false
A sharded topology is not single.
200 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 200 def single?; false; end |
#standalone_discovered ⇒ Topology::Sharded
Notify the topology that a standalone was discovered.
220 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 220 def standalone_discovered; self; end |
#unknown? ⇒ false
A sharded topology is not unknown.
210 |
# File 'lib/mongo/cluster/topology/sharded.rb', line 210 def unknown?; false; end |