View Javadoc
1   /*
2    * #%L
3    * ServerStatus.java - mongodb-async-driver - Allanbank Consulting, Inc.
4    * %%
5    * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.allanbank.mongodb.client.message;
21  
22  import com.allanbank.mongodb.bson.Document;
23  import com.allanbank.mongodb.bson.builder.BuilderFactory;
24  import com.allanbank.mongodb.bson.builder.DocumentBuilder;
25  import com.allanbank.mongodb.bson.impl.ImmutableDocument;
26  
27  /**
28   * Provides a convenient mechanism for creating a <a
29   * href="http://docs.mongodb.org/manual/reference/command/serverStatus/"
30   * >serverStatus</a> command.
31   * <p>
32   * This is a helper class for retrieving the status of a MongoDB server. The
33   * results of this command will look like: <blockquote>
34   * 
35   * <pre>
36   * <code>
37   * {
38   *     "host" : "mongos.example.com",
39   *     "version" : "1.8.2",
40   *     "process" : "mongos",
41   *     "uptime" : 1403,
42   *     "localTime" : ISODate("2011-12-06T00:11:56.822Z"),
43   *     "mem" : {
44   *         "resident" : 5,
45   *         "virtual" : 621,
46   *         "supported" : true
47   *     },
48   *     "connections" : {
49   *         "current" : 1,
50   *         "available" : 818
51   *     },
52   *     "extra_info" : {
53   *         "note" : "fields vary by platform",
54   *         "heap_usage_bytes" : 94560,
55   *         "page_faults" : 0
56   *     },
57   *     "opcounters" : {
58   *         "insert" : 0,
59   *         "query" : 9,
60   *         "update" : 0,
61   *         "delete" : 0,
62   *         "getmore" : 0,
63   *         "command" : 33
64   *     },
65   *     "ops" : {
66   *         "sharded" : {
67   *             "insert" : 0,
68   *             "query" : 0,
69   *             "update" : 0,
70   *             "delete" : 0,
71   *             "getmore" : 0,
72   *             "command" : 0
73   *         },
74   *         "notSharded" : {
75   *             "insert" : 0,
76   *             "query" : 9,
77   *             "update" : 0,
78   *             "delete" : 0,
79   *             "getmore" : 0,
80   *             "command" : 33
81   *         }
82   *     },
83   *     "shardCursorType" : {
84   * 
85   *     },
86   *     "asserts" : {
87   *         "regular" : 0,
88   *         "warning" : 0,
89   *         "msg" : 0,
90   *         "user" : 3,
91   *         "rollovers" : 0
92   *     },
93   *     "network" : {
94   *         "bytesIn" : 3205,
95   *         "bytesOut" : 6698,
96   *         "numRequests" : 45
97   *     },
98   *     "ok" : 1
99   * }
100  * </code>
101  * </pre>
102  * 
103  * </blockquote>
104  * </p>
105  * 
106  * @api.no This class is <b>NOT</b> part of the drivers API. This class may be
107  *         mutated in incompatible ways between any two releases of the driver.
108  * @copyright 2011-2013, Allanbank Consulting, Inc., All Rights Reserved
109  */
110 public class ServerStatus extends AdminCommand {
111 
112     /** The serverStatus "query" document. */
113     public static final Document SERVER_STATUS;
114 
115     static {
116         final DocumentBuilder builder = BuilderFactory.start();
117         builder.addInteger("serverStatus", 1);
118         SERVER_STATUS = new ImmutableDocument(builder);
119     }
120 
121     /**
122      * Create a new ServerStatus command.
123      */
124     public ServerStatus() {
125         super(SERVER_STATUS);
126     }
127 }