summaryrefslogtreecommitdiff
path: root/client/connpool.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-12-01 23:53:52 -0500
committerEliot Horowitz <eliot@10gen.com>2010-12-02 00:29:34 -0500
commit28b1cff00dcfa91cc69a3928bae48d840f287714 (patch)
treebe3520e2fb36926713d105c1244de4ee09606bf6 /client/connpool.cpp
parent53c8e5e3665e5650aaba28f45d5bd2c6fba96e4b (diff)
downloadmongo-28b1cff00dcfa91cc69a3928bae48d840f287714.tar.gz
track pooled connections by type
Diffstat (limited to 'client/connpool.cpp')
-rw-r--r--client/connpool.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/client/connpool.cpp b/client/connpool.cpp
index 9b1bf13f038..25098190e85 100644
--- a/client/connpool.cpp
+++ b/client/connpool.cpp
@@ -79,6 +79,13 @@ namespace mongo {
// if connection has been idle for an hour, kill it
return ( now - when ) < 3600;
}
+
+ void PoolForHost::createdOne( DBClientBase * base){
+ if ( _created == 0 )
+ _type = base->type();
+ _created++;
+ }
+
// ------ DBConnectionPool ------
DBConnectionPool pool;
@@ -93,7 +100,7 @@ namespace mongo {
{
scoped_lock L(_mutex);
PoolForHost& p = _pools[host];
- p.createdOne();
+ p.createdOne( conn );
}
onCreate( conn );
@@ -171,6 +178,9 @@ namespace mongo {
int avail = 0;
long long created = 0;
+
+ map<ConnectionString::ConnectionType,long long> createdByType;
+
{
scoped_lock lk( _mutex );
for ( map<string,PoolForHost>::iterator i=_pools.begin(); i!=_pools.end(); ++i ){
@@ -182,9 +192,20 @@ namespace mongo {
avail += i->second.numAvailable();
created += i->second.numCreated();
+
+ long long& x = createdByType[i->second.type()];
+ x += i->second.numCreated();
}
}
bb.done();
+
+ {
+ BSONObjBuilder temp( bb.subobjStart( "createdByType" ) );
+ for ( map<ConnectionString::ConnectionType,long long>::iterator i=createdByType.begin(); i!=createdByType.end(); ++i ){
+ temp.appendNumber( ConnectionString::typeToString( i->first ) , i->second );
+ }
+ temp.done();
+ }
b.append( "totalAvailable" , avail );
b.appendNumber( "totalCreated" , created );