Skip to content

Isdbgrid documentation #316

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

Merged
merged 4 commits into from
Oct 15, 2012
Merged
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
21 changes: 21 additions & 0 deletions source/core/sharding-internals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,27 @@ member has replicated changes before allowing new chunk migrations.
.. _config-database:
.. _sharding-internals-config-database:

Determine if You are Connected to a :program:`mongos`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If your application must determine whether it is connected to a
:program:`mongos`, use the :dbcommand:`isMaster` command. If the
application is connected to a :program:`mongos`, the :dbcommand:`isMaster`
command returns a document with the string ``isdbgrid`` in the ``msg``
field. For example:

.. code-block:: javascript

{
"ismaster" : true,
"msg" : "isdbgrid",
"maxBsonObjectSize" : 16777216,
"ok" : 1
}

If the application is instead connected to a :program:`mongod`, the
returned document does not include the ``isdbgrid`` string.

Config Database
---------------

Expand Down
39 changes: 27 additions & 12 deletions source/reference/command/isdbGrid.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
========
isdbGrid
isdbgrid
========

.. default-domain:: mongodb

.. dbcommand:: isdbGrid
.. dbcommand:: isdbgrid

Use this command to determine if the process is a :program:`mongos`
or a :program:`mongod`. Consider the following command prototype:
This command verifies that a process is a :program:`mongos`.

If you issue the :dbcommand:`isdbgrid` command when connected to a
:program:`mongos`, the response document includes the ``isdbgrid``
field set to ``1``. The returned document is similar to the
following:

.. code-block:: javascript

{ isdbGrid: 1 }
{ "isdbgrid" : 1, "hostname" : "app.example.net", "ok" : 1 }

If connected to a :program:`mongos`, the response document
resembles the following:
If you issue the :dbcommand:`isdbgrid` command when connected to a
:program:`mongod`, MongoDB returns an error document. The
:dbcommand:`isdbgrid` command is not available to :program:`mongod`.
The error document, however, also includes a line that reads
``"isdbgrid" : 1``, just as in the document returned for a
:program:`mongos`. The error document is similar to the following:

.. code-block:: javascript

{ "isdbgrid" : 1, "hostname" : "app.example.net", "ok" : 1 }

You can also use the :dbcommand:`isMaster` command, which when
connected to a :program:`mongos`, contains the string
``isdbgrid`` in the ``msg`` field of its output document.
{
"errmsg" : "no such cmd: isdbgrid",
"bad cmd" : {
"isdbgrid" : 1
},
"ok" : 0
}

You can instead use the :dbcommand:`isMaster` command to determine
connection to a :program:`mongos`. When connected to a
:program:`mongos`, the :dbcommand:`isMaster` command returns a document that
contains the string ``isdbgrid`` in the ``msg`` field.