From 1e3e96d8d47e459f82d7a777cc86447c704face2 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Mon, 15 Oct 2012 16:02:46 -0400 Subject: [PATCH 1/4] changes to isdbgrid documentation --- source/core/sharding-internals.txt | 24 ++++++++++++++++++ source/reference/command/isdbGrid.txt | 36 ++++++++++++++++++--------- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/source/core/sharding-internals.txt b/source/core/sharding-internals.txt index 5d93486f127..3eaba8aa8bc 100644 --- a/source/core/sharding-internals.txt +++ b/source/core/sharding-internals.txt @@ -511,6 +511,30 @@ 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 :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. + +As another option, you can use the :dbcommand:`isdbgrid` command. This +command, however, has limitations. See :dbcommand:`isdbgrid`. + Config Database --------------- diff --git a/source/reference/command/isdbGrid.txt b/source/reference/command/isdbGrid.txt index 07e39bda3f4..79ef63841e6 100644 --- a/source/reference/command/isdbGrid.txt +++ b/source/reference/command/isdbGrid.txt @@ -1,26 +1,38 @@ ======== -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`. - .. code-block:: javascript - - { isdbGrid: 1 } - - If connected to a :program:`mongos`, the response document + If you issue the :dbcommand:`isdbgrid` command when connected to a :program:`mongos`, the response document resembles 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. + However, if you issue the :dbcommand:`isdbgrid` command when conneted + to a :program:`mongod`, the returned document also might include a + line that reads ``"isdbgrid" : 1``, though in this case as part of an + error message. The :dbcommand:`isdbgrid` command is not available to + :program:`mongod` and returns an error document similar to the following: + + .. code-block:: + + { + "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` returns a document that + contains the string ``isdbgrid`` in the ``msg`` field. From 4de70b79d7a8c9f42822a449b643916047e0cd79 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Mon, 15 Oct 2012 16:08:01 -0400 Subject: [PATCH 2/4] fixed syntax error --- source/reference/command/isdbGrid.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/reference/command/isdbGrid.txt b/source/reference/command/isdbGrid.txt index 79ef63841e6..4924e33b2a2 100644 --- a/source/reference/command/isdbGrid.txt +++ b/source/reference/command/isdbGrid.txt @@ -21,7 +21,7 @@ isdbgrid error message. The :dbcommand:`isdbgrid` command is not available to :program:`mongod` and returns an error document similar to the following: - .. code-block:: + .. code-block:: javascript { "errmsg" : "no such cmd: isdbgrid", From 6e652eee7496b0bf89eec46d588c207b51bb208d Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Mon, 15 Oct 2012 16:26:15 -0400 Subject: [PATCH 3/4] minor: edits --- source/core/sharding-internals.txt | 2 +- source/reference/command/isdbGrid.txt | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/core/sharding-internals.txt b/source/core/sharding-internals.txt index 3eaba8aa8bc..d2d6bcc20ec 100644 --- a/source/core/sharding-internals.txt +++ b/source/core/sharding-internals.txt @@ -516,7 +516,7 @@ 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 :program:`mongos`, the :dbcommand:`isMaster` +application is connected to a :program:`mongos`, the :dbcommand:`isMaster` command returns a document with the string ``isdbgrid`` in the ``msg`` field. For example: diff --git a/source/reference/command/isdbGrid.txt b/source/reference/command/isdbGrid.txt index 4924e33b2a2..aa8afb8f019 100644 --- a/source/reference/command/isdbGrid.txt +++ b/source/reference/command/isdbGrid.txt @@ -8,18 +8,21 @@ isdbgrid 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 - resembles the following: + 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, "hostname" : "app.example.net", "ok" : 1 } - However, if you issue the :dbcommand:`isdbgrid` command when conneted - to a :program:`mongod`, the returned document also might include a - line that reads ``"isdbgrid" : 1``, though in this case as part of an - error message. The :dbcommand:`isdbgrid` command is not available to - :program:`mongod` and returns an error document similar to 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 @@ -33,6 +36,6 @@ isdbgrid You can instead use the :dbcommand:`isMaster` command to determine connection to a :program:`mongos`. When connected to a - :program:`mongos`, the :dbcommand:`isMaster` returns a document that + :program:`mongos`, the :dbcommand:`isMaster` command returns a document that contains the string ``isdbgrid`` in the ``msg`` field. From 00bf8d93a02f9c6574b4e6eeb9b0aa235bcbf8cd Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Mon, 15 Oct 2012 17:19:59 -0400 Subject: [PATCH 4/4] minor edit --- source/core/sharding-internals.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/core/sharding-internals.txt b/source/core/sharding-internals.txt index d2d6bcc20ec..a76bdcf7c99 100644 --- a/source/core/sharding-internals.txt +++ b/source/core/sharding-internals.txt @@ -532,9 +532,6 @@ field. For example: If the application is instead connected to a :program:`mongod`, the returned document does not include the ``isdbgrid`` string. -As another option, you can use the :dbcommand:`isdbgrid` command. This -command, however, has limitations. See :dbcommand:`isdbgrid`. - Config Database ---------------