|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mongodb.tools.ConnectionPoolStat
public class ConnectionPoolStat
A simple class that formats Mongo Java driver connection pool statistics in an easily-accessible JSON format. It can be used to get statistics on connection pool in the same VM by using the no-args constructor, or in any VM by using the constructor that takes an MBeanServerConnection.
This class also exposes a command line interface modeled after mongostat. For usage, run:
java -cp mongo.jar com.mongodb.util.management.jmx.ConnectionPoolStat --help}
| Constructor Summary | |
|---|---|
ConnectionPoolStat()
Use the platform MBean server. |
|
ConnectionPoolStat(MBeanServerConnection mBeanConnection)
Use the given MBean server connection to access statistics for connection pools. |
|
| Method Summary | |
|---|---|
String |
getStats()
Gets the statistics for all Mongo connection pools registered with the MBean server used by this instance. |
static void |
main(String[] args)
Command line interface for displaying connection pool stats. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConnectionPoolStat(MBeanServerConnection mBeanConnection)
mBeanConnection - the MBean server to connect topublic ConnectionPoolStat()
ManagementFactory.getPlatformMBeanServer()| Method Detail |
|---|
public String getStats()
throws JMException,
IOException
{ pools : [
{ objectName: 'com.mongodb:type=ConnectionPool,host=localhost/127.0.0.1,port=27018,instance=1',
host: 'localhost', port: 27018, maxSize: 10, total: 10, inUse: 3,
inUseConnections: [
{ namespace: 'FindContention.test', opCode: 'OP_QUERY', query: { }, numDocuments: 1, threadName: 'pool-2-thread-19', durationMS: 843, localPort: 64062 },
{ namespace: 'FindContention.test', opCode: 'OP_QUERY', query: { }, numDocuments: 1, threadName: 'pool-2-thread-1', durationMS: 4331, localPort: 64095 },
{ namespace: 'FindContention.test', opCode: 'OP_QUERY', query: { }, numDocuments: 1, threadName: 'pool-2-thread-16', durationMS: 4343, localPort: 64087 }
]
},
{ objectName: 'com.mongodb:type=ConnectionPool,host=localhost/127.0.0.1,port=27017,instance=1',
host: 'localhost', port: 27017, maxSize: 10, total: 10, inUse: 2,
inUseConnections: [
{ namespace: 'FindContention.test', opCode: 'OP_QUERY', query: { }, numDocuments: 1, threadName: 'pool-2-thread-5', durationMS: 920, localPort: 64093 },
{ namespace: 'FindContention.test', opCode: 'OP_QUERY', query: { }, numDocuments: 1, threadName: 'pool-2-thread-11', durationMS: 1468, localPort: 64068 },
]
}
]
}
JMException - for any JMX-related exceptions
IOException - for any I/O exceptions
public static void main(String[] args)
throws Exception
args - program arguments
Exception - JMX-related exceptionsprintUsage()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||