Skip to content

Commit 62c7f3f

Browse files
committed
convenience method to access the replset name
1 parent 8452be3 commit 62c7f3f

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/main/com/mongodb/DBTCPConnector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ public List<ServerAddress> getServerAddressList() {
277277
return null;
278278
}
279279

280+
public ReplicaSetStatus getReplicaSetStatus() {
281+
return _rsStatus;
282+
}
283+
280284
public String getConnectPoint(){
281285
ServerAddress master = getAddress();
282286
return master != null ? master.toString() : null;

src/main/com/mongodb/Mongo.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,22 @@ public String getConnectPoint(){
395395
return _connector.getConnectPoint();
396396
}
397397

398+
/**
399+
* Gets the underlying TCP connector
400+
* @return
401+
*/
402+
DBTCPConnector getConnector() {
403+
return _connector;
404+
}
405+
406+
/**
407+
* Gets the replica set status object
408+
* @return
409+
*/
410+
public ReplicaSetStatus getReplicaSetStatus() {
411+
return _connector.getReplicaSetStatus();
412+
}
413+
398414
/**
399415
* Gets the address of the current master
400416
* @return the address
@@ -498,10 +514,6 @@ void _applyMongoOptions() {
498514
setWriteConcern( _options.getWriteConcern() );
499515
}
500516

501-
DBTCPConnector getConnector() {
502-
return _connector;
503-
}
504-
505517
final ServerAddress _addr;
506518
final List<ServerAddress> _addrs;
507519
final MongoOptions _options;

src/main/com/mongodb/ReplicaSetStatus.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* slave delay
1818
* tags (when we do it)
1919
*/
20-
class ReplicaSetStatus {
20+
public class ReplicaSetStatus {
2121

2222
static final Logger _rootLogger = Logger.getLogger( "com.mongodb.ReplicaSetStatus" );
2323
static final int UNAUTHENTICATED_ERROR_CODE = 10057;
@@ -38,6 +38,10 @@ boolean ready(){
3838
return _setName != null;
3939
}
4040

41+
public String getName() {
42+
return _setName;
43+
}
44+
4145
void _checkClosed(){
4246
if ( _closed )
4347
throw new IllegalStateException( "ReplicaSetStatus closed" );

0 commit comments

Comments
 (0)