Skip to content

Commit 1312fbb

Browse files
JAVA-336: pool/mongo description
1 parent 3850087 commit 1312fbb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/com/mongodb/DBPortPool.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ void close(){
101101
}
102102

103103
private ObjectName createObjectName( ServerAddress addr ) throws MalformedObjectNameException {
104-
return new ObjectName( "com.mongodb:type=ConnectionPool,host=" + addr.toString().replace( ":" , ",port=" ) + ",instance=" + hashCode() );
104+
String name = "com.mongodb:type=ConnectionPool,host=" + addr.toString().replace( ":" , ",port=" ) + ",instance=" + hashCode();
105+
if ( _options.description != null )
106+
name += ",description=" + _options.description;
107+
return new ObjectName( name );
105108
}
106109

107110
final MongoOptions _options;

src/main/com/mongodb/MongoOptions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package com.mongodb;
2020

21-
import java.net.*;
2221

2322
/**
2423
* Various settings for the driver
@@ -59,6 +58,11 @@ else if (safe)
5958
return WriteConcern.NORMAL;
6059
}
6160

61+
/**
62+
* <p>The description for <code>Mongo</code> instances created with these options. This is used in various places like logging.</p>
63+
*/
64+
public String description;
65+
6266
/**
6367
* <p>The number of connections allowed per host
6468
* (the pool size, per host)</p>
@@ -159,6 +163,7 @@ else if (safe)
159163

160164
public String toString(){
161165
StringBuilder buf = new StringBuilder();
166+
buf.append( "description=" ).append( description ).append( ", " );
162167
buf.append( "connectionsPerHost=" ).append( connectionsPerHost ).append( ", " );
163168
buf.append( "threadsAllowedToBlockForConnectionMultiplier=" ).append( threadsAllowedToBlockForConnectionMultiplier ).append( ", " );
164169
buf.append( "maxWaitTime=" ).append( maxWaitTime ).append( ", " );

0 commit comments

Comments
 (0)