Skip to content

Commit 5b8538e

Browse files
committed
convenience method to access connection pool info
1 parent 62c7f3f commit 5b8538e

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/main/com/mongodb/DBPortPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.lang.management.*;
3030
import javax.management.*;
3131

32-
class DBPortPool extends SimplePool<DBPort> {
32+
public class DBPortPool extends SimplePool<DBPort> {
3333

3434
static class Holder {
3535

src/main/com/mongodb/DBTCPConnector.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import org.bson.*;
2727

28-
class DBTCPConnector implements DBConnector {
28+
public class DBTCPConnector implements DBConnector {
2929

3030
static Logger _logger = Logger.getLogger( Bytes.LOGGER.getName() + ".tcp" );
3131
static Logger _createLogger = Logger.getLogger( _logger.getName() + ".connect" );
@@ -445,11 +445,26 @@ public void close(){
445445
_myPort = null;
446446
}
447447

448-
void updatePortPool(ServerAddress addr) {
448+
/**
449+
* Assigns a new DBPortPool for a given ServerAddress.
450+
* This is used to obtain a new pool when the resolved IP of a host changes, for example.
451+
* User application should not have to call this method directly.
452+
* @param addr
453+
*/
454+
public void updatePortPool(ServerAddress addr) {
449455
// just remove from map, a new pool will be created lazily
450456
_portHolder._pools.remove(addr);
451457
}
452458

459+
/**
460+
* Gets the DBPortPool associated with a ServerAddress.
461+
* @param addr
462+
* @return
463+
*/
464+
public DBPortPool getDBPortPool(ServerAddress addr) {
465+
return _portHolder.get(addr);
466+
}
467+
453468
public boolean isOpen(){
454469
return ! _closed;
455470
}

src/main/com/mongodb/Mongo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public String getConnectPoint(){
399399
* Gets the underlying TCP connector
400400
* @return
401401
*/
402-
DBTCPConnector getConnector() {
402+
public DBTCPConnector getConnector() {
403403
return _connector;
404404
}
405405

0 commit comments

Comments
 (0)