Class: Mongo::Cluster::Topology::ReplicaSetNoPrimary
- Defined in:
- lib/mongo/cluster/topology/replica_set_no_primary.rb
Overview
Defines behavior when a cluster is in replica set topology, and there is no primary or the primary has not yet been discovered by the driver.
Direct Known Subclasses
Constant Summary collapse
- NAME =
Deprecated.
The display name for the topology.
'Replica Set'.freeze
Constants included from Loggable
Instance Attribute Summary
Attributes inherited from Base
#compatibility_error, #logical_session_timeout, #monitoring, #options, #server_descriptions
Attributes included from Monitoring::Publishable
Instance Method Summary collapse
-
#display_name ⇒ String
Get the display name.
- #has_readable_server?(cluster, server_selector = nil) ⇒ true, false deprecated Deprecated.
-
#has_writable_server?(cluster) ⇒ true, false
Determine if the topology would select a writable server for the provided candidates.
-
#replica_set? ⇒ true
A replica set topology is a replica set.
-
#servers(servers) ⇒ Array<Server>
Select appropriate servers for this topology.
-
#sharded? ⇒ false
A replica set topology is not sharded.
-
#single? ⇒ false
A replica set topology is not single.
- #summary ⇒ Object
-
#unknown? ⇒ false
A replica set topology is not unknown.
Methods inherited from Base
#addresses, #compatible?, #data_bearing_servers?, #initialize, #max_election_id, #max_set_version, #new_max_election_id, #new_max_set_version, #replica_set_name, #server_hosts_match_any?
Methods included from Monitoring::Publishable
#publish_cmap_event, #publish_event, #publish_sdam_event
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Constructor Details
This class inherits a constructor from Mongo::Cluster::Topology::Base
Instance Method Details
#display_name ⇒ String
Get the display name.
43 44 45 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 43 def display_name self.class.name.gsub(/.*::/, '') end |
#has_readable_server?(cluster, server_selector = nil) ⇒ true, false
Determine if the topology would select a readable server for the provided candidates and read preference.
80 81 82 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 80 def has_readable_server?(cluster, server_selector = nil) !(server_selector || ServerSelector.primary).try_select_server(cluster).nil? end |
#has_writable_server?(cluster) ⇒ true, false
Determine if the topology would select a writable server for the provided candidates.
95 96 97 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 95 def has_writable_server?(cluster) !ServerSelector.primary.try_select_server(cluster).nil? end |
#replica_set? ⇒ true
A replica set topology is a replica set.
107 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 107 def replica_set?; true; end |
#servers(servers) ⇒ Array<Server>
Select appropriate servers for this topology.
119 120 121 122 123 124 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 119 def servers(servers) servers.select do |server| (replica_set_name.nil? || server.replica_set_name == replica_set_name) && server.primary? || server.secondary? end end |
#sharded? ⇒ false
A replica set topology is not sharded.
134 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 134 def sharded?; false; end |
#single? ⇒ false
A replica set topology is not single.
144 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 144 def single?; false; end |
#summary ⇒ Object
This method is experimental and subject to change.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 51 def summary details = server_descriptions.keys.join(',') if details != '' details << ',' end details << "name=#{replica_set_name}" if max_set_version details << ",v=#{max_set_version}" end if max_election_id details << ",e=#{max_election_id && max_election_id.to_s.sub(/^0+/, '')}" end "#{display_name}[#{details}]" end |
#unknown? ⇒ false
A replica set topology is not unknown.
154 |
# File 'lib/mongo/cluster/topology/replica_set_no_primary.rb', line 154 def unknown?; false; end |