Skip to content

Commit 0666a02

Browse files
author
Sam Kleinman
committed
DOCS-305 tag aware sharding reference
1 parent 872dc29 commit 0666a02

File tree

2 files changed

+99
-16
lines changed

2 files changed

+99
-16
lines changed

source/reference/javascript.txt

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Query and Update Methods
118118

119119
.. function:: db.collection.insert(document)
120120

121-
:param document: Specifies a document to save to the ``collection``.
121+
:param document: Specify a document to save to the ``collection``.
122122

123123
:param array documents: Optional alternate. After version 2.2, if
124124
you pass an array to :func:`insert()
@@ -132,11 +132,11 @@ Query and Update Methods
132132

133133
.. function:: db.collection.save(document)
134134

135-
:param document: Specifies a document to save to the ``collection``.
135+
:param document: Specify a document to save to the ``collection``.
136136

137137
If :term:`document` has an `_id` field, then perform an
138-
:func:`db.collection.update()` with no
139-
:ref:`update-operators<update-operators>`. Otherwise, insert a new
138+
:func:`db.collection.update()` with no :ref:`update-operators
139+
<update-operators>` as an :term:`upsert`. Otherwise, insert a new
140140
document with fields from `document` and a newly generated
141141
ObjectId() for the ``_id`` field.
142142

@@ -474,17 +474,17 @@ Data Aggregation
474474
The :func:`db.collection.group()` accepts a single :term:`document` that
475475
contains the following:
476476

477-
:field key: Specify one or more fields to group by.
477+
:field key: Specifies one or more fields to group by.
478478

479-
:field reduce: Specify a reduce function that operates over all the
479+
:field reduce: Specifies a reduce function that operates over all the
480480
iterated objects. Typically these aggregator
481481
functions perform some sort of summing or
482482
counting. The reduce function takes two arguments:
483483
the current document and an aggregation counter
484484
object.
485485

486486
:field initial: The starting value of the aggregation counter
487-
object.
487+
object.
488488

489489
:field keyf: Optional. An optional function that returns a "key
490490
object" for use as the grouping key. Use
@@ -728,8 +728,8 @@ Database
728728

729729
:param string password: Specifies the corresponding password.
730730

731-
:param boolean readOnly: Optionally restricts a user to read-privileges
732-
only. Defaults to false.
731+
:param boolean readOnly: Optional. Restrict a user to
732+
read-privileges only. Defaults to false.
733733

734734
Use this function to create new database users, by specifying a
735735
username and password as arguments to the command. If you want to
@@ -1110,7 +1110,7 @@ Database
11101110

11111111
.. function:: db.setProfilingLevel(level, [slowms])
11121112

1113-
:param level: Specify a profiling level, see list of possible
1113+
:param level: Specifies a profiling level, see list of possible
11141114
values below.
11151115

11161116
:param slowms: Optionally modify the threshold for the profile to
@@ -1730,6 +1730,75 @@ Sharding
17301730
cluster`, including data regarding the distribution of
17311731
chunks.
17321732

1733+
.. function:: sh.addShardTag(shard, tag)
1734+
1735+
.. versionadded:: 2.2
1736+
1737+
:param shard: Specifies the name of the shard that you want to give
1738+
a specific tag.
1739+
1740+
:param tag: Specifies the name of the tag that you want to add to
1741+
the shard.
1742+
1743+
:func:`sh.addShardTag()` associates a shard with a tag or
1744+
identifier. MongoDB can use these identifiers, to "home" or attach
1745+
(i.e. with :func:`sh.addTagRange()`) specific data to a specific
1746+
shard.
1747+
1748+
Always issue :func:`sh.addShardTag()` when connected to a
1749+
:program:`mongos` instance. The following example adds three tags,
1750+
``LGA``, ``EWR``, and ``JFK``, to three shards:
1751+
1752+
.. code-block:: javascript
1753+
1754+
sh.addShardTag("shard0000", "LGA")
1755+
sh.addShardTag("shard0001", "EWR")
1756+
sh.addShardTag("shard0002", "JFK")
1757+
1758+
.. function:: sh.addTagRange(namespace, minimum, maximum, tag)
1759+
1760+
.. versionadded:: 2.2
1761+
1762+
:param namespace: Specifies the namespace, in the form of
1763+
``<database>.<collection>`` of the sharded
1764+
collection that you would like to tag.
1765+
1766+
:param minimum: Specifies the minimum value of the :term:`shard
1767+
key` range to include in the tag. Specify the
1768+
minimum value in the form of
1769+
``<fieldname>:<value>``.
1770+
1771+
:param maximum: Specifies the maximum value of the shard key range
1772+
to include in the tag. Specify the minimum value
1773+
in the form of ``<fieldname>:<value>``.
1774+
1775+
:param tag: Specifies the name of the tag to attach the range
1776+
specified by the ``minimum`` and ``maximum`` arguments
1777+
to.
1778+
1779+
:func:`sh.addTagRange()` attaches a range of values of the shard
1780+
key to a shard tag created using the :func:`sh.addShardTag()`
1781+
helper. Use this operation to ensure that the documents that exist
1782+
within the specified range exist on shards that have a matching
1783+
tag.
1784+
1785+
Always issue :func:`sh.addTagRange()` when connected to a
1786+
:program:`mongos` instance.
1787+
1788+
.. function:: sh.removeShardTag(shard, tag)
1789+
1790+
.. versionadded:: 2.2
1791+
1792+
:param shard: Specifies the name of the shard that you want
1793+
to remove a tag from.
1794+
1795+
:param tag: Specifies the name of the tag that you want to remove
1796+
from the shard.
1797+
1798+
Removes the association between a tag and a shard. Always issue
1799+
:func:`sh.removeShardTag()` when connected to a :program:`mongos`
1800+
instance.
1801+
17331802
.. function:: sh.help()
17341803

17351804
:returns: a basic help text for all sharding related shell

source/release-notes/2.2.txt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,26 @@ reporting for concurrency and use, see the :ref:`locks` and
151151

152152
.. TODO add links to current op output documentation when it happens.
153153

154-
Tag Aware Sharding
155-
``````````````````
156-
157-
:wiki:`Documentation <Tag+Aware+Sharding>`
158-
159-
.. TODO see kristina's blog post.
154+
Improved Data Center Awareness with Tag Aware Sharding
155+
``````````````````````````````````````````````````````
156+
157+
In 2.2, MongoDB adds additional support for geographically distributed
158+
database systems. This "tag aware" sharding combines with work done
159+
with :ref:`read preferences <replica-set-read-preference>` and
160+
:ref:`tag sets <replica-set-configuration-tag-sets>` to make it
161+
possible to ensure that data in a geographically distributed sharded
162+
cluster is always closest to the application servers that will use
163+
that data the most.
164+
165+
See the documentation of the following helpers in the :program:`mongo`
166+
shell that support tagged sharding configuration:
167+
168+
- :func:`sh.addShardTag()`
169+
- :func:`sh.addTagRange()`
170+
- :func:`sh.removeShardTag()`
171+
172+
Also, see the :wiki:`wiki page for tag aware sharding
173+
<Tag+Aware+Sharding>`.
160174

161175
Fully Supported Read Preference Semantics
162176
`````````````````````````````````````````

0 commit comments

Comments
 (0)