Skip to content

DOCS-1492 sh.moveChunk, sh.shardCollection, et al. #1053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions source/reference/method/sh.moveChunk-param.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
object:
name:
type:
name: sh.moveChunk()
type: method
field:
optional: false
type: param
name:
type:
name: namespace
type: string
position: 1
description: ""
description: |
The :term:`namespace` of the sharded collection that contains the
chunk to migrate.
---
object:
name:
type:
name: sh.moveChunk()
type: method
field:
optional:
optional: false
type: param
name:
type:
name: query
type: document
position: 2
description: ""
description: |
An equality match on the shard key. This selects the chunk to move.
---
object:
name:
type:
name: sh.moveChunk()
type: method
field:
optional:
optional: false
type: param
name:
type:
name: destination
type: string
position: 3
description: ""
description: |
The name of the shard to move.
...
31 changes: 16 additions & 15 deletions source/reference/method/sh.moveChunk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,16 @@ sh.moveChunk()

.. default-domain:: mongodb

.. method:: sh.moveChunk(collection, query, destination)
Definition
----------

:param string collection:

Specifies the sharded collection containing the chunk to
migrate.

:param document query:

A document that specifies an equality match on the shard key,
which selects the chunk to move.

:param string destination:

Specifies the name of the shard that you wish to move the
designated chunk to.
.. method:: sh.moveChunk(namespace, query, destination)

Moves the chunk containing the document specified by the ``query``
to the shard described by ``destination``.

.. include:: /reference/method/sh.moveChunk-param.rst

This method provides a wrapper around the
:dbcommand:`moveChunk`. In most circumstances, allow the
:term:`balancer` to automatically migrate :term:`chunks <chunk>`,
Expand All @@ -33,3 +23,14 @@ sh.moveChunk()
:method:`sh.splitFind()`, :doc:`/sharding`, and :ref:`chunk
migration <sharding-chunk-migration>`.

Example
-------

Given the ``people`` collection in the ``records`` database, the
following command finds the chunk that contains the documents with the
``zipcode`` field set to ``53187`` and then moves that chunk to the
shard named ``shard0019``:

.. code-block:: javascript

sh.moveChunk("records.people", { zipcode: 53187 }, "shard0019")
42 changes: 25 additions & 17 deletions source/reference/method/sh.shardCollection-param.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
object:
name:
type:
name: sh.shardCollection()
type: method
field:
optional: false
type: param
name:
type:
name: namespace
type: string
position: 1
description: ""
description: |
The :term:`namespace` of the collection to shard.
---
object:
name:
type:
name: sh.shardCollection()
type: method
field:
optional:
optional: false
type: param
name:
type:
name: shard key
type: document
position: 2
description: ""
description: |
A :term:`document` that specifies the :term:`shard key` to use to
:term:`partition` and distribute objects among the shards. A shard key
may be one field or multiple fields. A shard key with multiple fields
is called a "compound shard key."
---
object:
name:
type:
name: sh.shardCollection()
type: method
field:
optional:
optional: false
type: param
name:
type:
name: unique
type: Boolean
position: 3
description: ""
description: |
When true, ensures that the underlying index enforces a unique
constraint. :term:`Hashed shard keys <hashed shard key>` do not
support unique constraints.
...
37 changes: 17 additions & 20 deletions source/reference/method/sh.shardCollection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,14 @@ sh.shardCollection()

.. default-domain:: mongodb

.. method:: sh.shardCollection(namespace, key, unique)
Definition
----------

:param string namespace: The :term:`namespace` of the collection to shard.
.. method:: sh.shardCollection(namespace, shard key, unique)

:param document key:
Shards a collection according to a specified :term:`shard key`.

A :term:`document` containing a :term:`shard key` that the
sharding system uses to :term:`partition` and distribute objects
among the shards.

:param boolean unique:

When true, the ``unique`` option ensures that the underlying
index enforces a unique constraint. :term:`Hashed shard keys
<hashed shard key>` do not support unique constraints.

Shards the named collection, according to the specified
:term:`shard key`. Specify shard keys in the form of a :term:`document`.
Shard keys may refer to a single document field, or more typically
several document fields to form a "compound shard key."
.. include:: /reference/method/sh.shardCollection-param.rst

.. versionadded:: 2.4
Use the form ``{field: "hashed"}`` to create a
Expand All @@ -36,8 +24,17 @@ sh.shardCollection()

:dbcommand:`shardCollection` for additional options,
:doc:`/sharding`, :doc:`/core/sharded-clusters` for an overview of
sharding with MongoDB and
:doc:`/tutorial/deploy-shard-cluster` for a tutorial.
Also review :ref:`sharding-shard-key` regarding choosing a shard
sharding,
:doc:`/tutorial/deploy-shard-cluster` for a tutorial, and
:ref:`sharding-shard-key` for choosing a shard
key.

Example
-------

Given the ``people`` collection in the ``records`` database, the
following command shards the collection by the ``zipcode`` field:

.. code-block:: javascript

sh.shardCollection("records.people", { zipcode: 1} )
40 changes: 22 additions & 18 deletions source/reference/method/sh.waitForBalancer-param.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
object:
name:
type:
name: sh.waitForBalancer()
type: method
field:
optional: false
optional: true
type: param
name:
type:
name: wait
type: Boolean
position: 1
description: ""
description: |
Set this to ``true`` to wait for the balancer lock to change. The
default is ``false``, which waits until balancing stops.
---
object:
name:
type:
name: sh.waitForBalancer()
type: method
field:
optional:
optional: false
type: param
name:
type:
name: timeout
type: integer
position: 2
description: ""
description: |
Milliseconds to wait.
---
object:
name:
type:
name: sh.waitForBalancer()
type: method
field:
optional:
optional: false
type: param
name:
type:
name: interval
type: integer
position: 3
description: ""
description: |
Milliseconds to sleep.
...
27 changes: 6 additions & 21 deletions source/reference/method/sh.waitForBalancer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,12 @@ sh.waitForBalancer()

.. default-domain:: mongodb

.. method:: sh.waitForBalancer(onOrNot, timeout, interval)
Definition
----------

:param Boolean onOrNot: Whether to wait for the lock to be
on (``true``) or off (``false``).

:param integer timeout: Milliseconds to wait.

:param integer interval: Milliseconds to sleep.
.. method:: sh.waitForBalancer(wait, timeout, interval)

This is an internal method that waits for a change in the state of
the balancer.

:method:`sh.waitForBalancer()` is an internal method that waits for
a change in the state of the balancer.

.. seealso::

- :method:`sh.enableBalancing()`
- :method:`sh.disableBalancing()`
- :method:`sh.getBalancerHost()`
- :method:`sh.getBalancerState()`
- :method:`sh.isBalancerRunning()`
- :method:`sh.setBalancerState()`
- :method:`sh.startBalancer()`
- :method:`sh.stopBalancer()`
- :method:`sh.waitForBalancerOff()`
.. include:: /reference/method/sh.waitForBalancer-param.rst
37 changes: 20 additions & 17 deletions source/reference/method/sh.waitForPingChange-param.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
object:
name:
type:
name: sh.waitForPingChange()
type: method
field:
optional: false
type: param
name:
type:
name: active pings
type: array
position: 1
description: ""
description: |
An array of active pings from the :data:`~config.mongos` collection.
---
object:
name:
type:
name: sh.waitForPingChange()
type: method
field:
optional:
optional: false
type: param
name:
type:
name: timeout
type: integer
position: 2
description: ""
description: |
Milliseconds to wait for a change in ping state.
---
object:
name:
type:
name: sh.waitForPingChange()
type: method
field:
optional:
optional: false
type: param
name:
type:
name: interval
type: integer
position: 3
description: ""
description: |
Milliseconds to sleep in each waiting cycle.
...
15 changes: 6 additions & 9 deletions source/reference/method/sh.waitForPingChange.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ sh.waitForPingChange()

.. default-domain:: mongodb

.. method:: sh.waitForPingChange(activepings, timeout, interval)
Definition
----------

:param array activepings: An array of active pings from the
``config.mongos`` collection.

:param integer timeout: Milliseconds to wait for a change in ping state.

:param integer interval: Milliseconds to sleep in each waiting cycle.
.. method:: sh.waitForPingChange(active pings, timeout, interval)

:method:`sh.waitForPingChange()` waits for a change in ping state
of the one of the ``activepings``.
Waits for a change in ping state of one of the ``activepings``.

.. include:: /reference/method/sh.waitForPingChange-param.rst