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

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/cluster/topology/sharded.rb

Overview

Defines behaviour 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

Instance Method Summary collapse

Constructor Details

#initialize(options, seeds = []) ⇒ Sharded

Initialize the topology with the options.

Examples:

Initialize the topology.

Sharded.new(options)

Parameters:

  • options (Hash)

    The options.

Since:

  • 2.0.0



62
63
64
# File 'lib/mongo/cluster/topology/sharded.rb', line 62

def initialize(options, seeds = [])
  @options = options
end

Instance Method Details

#add_hosts?(description, servers) ⇒ false

Whether a server description’s hosts may be added to the cluster.

Examples:

Check if a description’s hosts may be added to the cluster.

topology.add_hosts?(description, servers)

Parameters:

Returns:

  • (false)

    A description’s hosts are never added to a sharded cluster.

Since:

  • 2.0.6



112
# File 'lib/mongo/cluster/topology/sharded.rb', line 112

def add_hosts?(description, servers); false; end

#display_nameString

Get the display name.

Examples:

Get the display name.

Sharded.display_name

Returns:

  • (String)

    The display name.

Since:

  • 2.0.0



37
38
39
# File 'lib/mongo/cluster/topology/sharded.rb', line 37

def display_name
  NAME
end

#elect_primary(description, servers) ⇒ Sharded

Elect a primary server within this topology.

Examples:

Elect a primary server.

topology.elect_primary(description, servers)

Parameters:

  • description (Server::Description)

    The description of the elected primary.

  • servers (Array<Server>)

    The list of known servers to the cluster.

Returns:

Since:

  • 2.0.0



52
# File 'lib/mongo/cluster/topology/sharded.rb', line 52

def elect_primary(description, servers); self; end

#remove_hosts?(description) ⇒ true

Whether a description can be used to remove hosts from the cluster.

the cluster.

topology.remove_hosts?(description)

Examples:

Check if a description can be used to remove hosts from

Parameters:

Returns:

  • (true)

    A description can always be used to remove hosts from a sharded cluster.

Since:

  • 2.0.6



126
# File 'lib/mongo/cluster/topology/sharded.rb', line 126

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.

Examples:

Check if a specific server can be removed from the cluster.

topology.remove_server?(description, server)

Parameters:

Returns:

  • (true, false)

    Whether the server can be removed from the cluster.

Since:

  • 2.0.6



139
140
141
142
# File 'lib/mongo/cluster/topology/sharded.rb', line 139

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.

Examples:

Is the topology a replica set?

Sharded.replica_set?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



74
# File 'lib/mongo/cluster/topology/sharded.rb', line 74

def replica_set?; false; end

#replica_set_namenil

Sharded topologies have no replica set name.

Examples:

Get the replica set name.

sharded.replica_set_name

Returns:

  • (nil)

    Always nil.

Since:

  • 2.0.0



84
# File 'lib/mongo/cluster/topology/sharded.rb', line 84

def replica_set_name; nil; 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



96
97
98
# File 'lib/mongo/cluster/topology/sharded.rb', line 96

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



152
# File 'lib/mongo/cluster/topology/sharded.rb', line 152

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



162
# File 'lib/mongo/cluster/topology/sharded.rb', line 162

def single?; false; end

#standalone_discoveredTopology::Sharded

Notify the topology that a standalone was discovered.

Examples:

Notify the topology that a standalone was discovered.

topology.standalone_discovered

Returns:

Since:

  • 2.0.6



182
# File 'lib/mongo/cluster/topology/sharded.rb', line 182

def standalone_discovered; self; end

#unknown?false

A sharded topology is not unknown.

Examples:

Is the topology unknown?

Sharded.unknown?

Returns:

  • (false)

    Always false.

Since:

  • 2.0.0



172
# File 'lib/mongo/cluster/topology/sharded.rb', line 172

def unknown?; false; end