Class: Mongo::Cluster::Topology::Sharded

Inherits:
Base
  • Object
show all
Includes:
NoReplicaSetOptions
Defined in:
build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb

Overview

Defines behavior for when a cluster is in sharded topology.

Since:

  • 2.0.0

Constant Summary collapse

NAME =

The display name for the topology.

Since:

  • 2.0.0

'Sharded'.freeze

Constants included from Loggable

Loggable::PREFIX

Instance Attribute Summary

Attributes inherited from Base

#compatibility_error, #logical_session_timeout, #monitoring, #options, #server_descriptions

Attributes included from Monitoring::Publishable

#monitoring

Instance Method Summary collapse

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

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_nameString

Get the display name.

Examples:

Get the display name.

Sharded.display_name

Returns:

  • (String)

    The display name.

Since:

  • 2.0.0



41
42
43
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 41

def display_name
  self.class.name.gsub(/.*::/, '')
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.

Examples:

Is a readable server present?

topology.has_readable_server?(cluster, server_selector)

Parameters:

  • cluster (Cluster)

    The cluster.

  • server_selector (ServerSelector) (defaults to: nil)

    The server selector.

Returns:

  • (true)

    A Sharded cluster always has a readable server.

Since:

  • 2.4.0



67
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 67

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.

Examples:

Is a writable server present?

topology.has_writable_server?(servers)

Parameters:

  • cluster (Cluster)

    The cluster.

Returns:

  • (true)

    A Sharded cluster always has a writable server.

Since:

  • 2.4.0



80
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 80

def has_writable_server?(cluster); true; end

#replica_set?false

A sharded topology is not a replica set.

Examples:

Is the topology a replica set?

Sharded.replica_set?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



90
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 90

def replica_set?; false; end

#servers(servers) ⇒ Array<Server>

Select appropriate servers for this topology.

Examples:

Select the servers.

Sharded.servers(servers)

Parameters:

  • servers (Array<Server>)

    The known servers.

Returns:

  • (Array<Server>)

    The mongos servers.

Since:

  • 2.0.0



102
103
104
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 102

def servers(servers)
  servers.select { |server| server.mongos? }
end

#sharded?true

A sharded topology is sharded.

Examples:

Is the topology sharded?

Sharded.sharded?

Returns:

  • (true)

    Always true.

Since:

  • 2.0.0



114
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 114

def sharded?; true; end

#single?false

A sharded topology is not single.

Examples:

Is the topology single?

Sharded.single?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



124
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 124

def single?; false; end

#summaryObject

Note:

This method is experimental and subject to change.

Since:

  • 2.7.0



49
50
51
52
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 49

def summary
  details = server_descriptions.keys.join(',')
  "#{display_name}[#{details}]"
end

#unknown?false

A sharded topology is not unknown.

Examples:

Is the topology unknown?

Sharded.unknown?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



134
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/topology/sharded.rb', line 134

def unknown?; false; end