@@ -92,13 +92,11 @@ public class Mongo {
92
92
93
93
private final Bytes .OptionHolder optionHolder ;
94
94
95
- private final Cluster cluster ;
96
95
private final BufferProvider bufferProvider = new PowerOfTwoBufferPool ();
97
96
98
97
private final ConcurrentLinkedQueue <ServerCursorAndNamespace > orphanedCursors = new ConcurrentLinkedQueue <ServerCursorAndNamespace >();
99
98
private final ExecutorService cursorCleaningService ;
100
99
private final MongoClientDelegate delegate ;
101
- private final ServerSessionPool serverSessionPool ;
102
100
103
101
/**
104
102
* Creates a Mongo instance based on a (single) mongodb node (localhost, default port)
@@ -312,8 +310,6 @@ public Mongo(
312
310
}
313
311
314
312
Mongo (final Cluster cluster , final MongoClientOptions options , final List <MongoCredential > credentialsList ) {
315
- this .cluster = cluster ;
316
- this .serverSessionPool = new ServerSessionPool (cluster );
317
313
this .options = options ;
318
314
this .readPreference = options .getReadPreference ();
319
315
this .writeConcern = options .getWriteConcern ();
@@ -392,7 +388,7 @@ public ReadPreference getReadPreference() {
392
388
* @throws MongoException if there's a failure
393
389
*/
394
390
public List <ServerAddress > getAllAddress () {
395
- return cluster .getSettings ().getHosts ();
391
+ return delegate . getCluster () .getSettings ().getHosts ();
396
392
}
397
393
398
394
/**
@@ -406,7 +402,7 @@ public List<ServerAddress> getServerAddressList() {
406
402
}
407
403
408
404
private ClusterDescription getClusterDescription () {
409
- return cluster .getDescription ();
405
+ return delegate . getCluster () .getDescription ();
410
406
}
411
407
412
408
/**
@@ -447,7 +443,7 @@ public MongoOptions getMongoOptions() {
447
443
public ReplicaSetStatus getReplicaSetStatus () {
448
444
ClusterDescription clusterDescription = getClusterDescription ();
449
445
return clusterDescription .getType () == REPLICA_SET && clusterDescription .getConnectionMode () == MULTIPLE
450
- ? new ReplicaSetStatus (cluster ) : null ; // this is intended behavior in 2.x
446
+ ? new ReplicaSetStatus (delegate . getCluster () ) : null ; // this is intended behavior in 2.x
451
447
}
452
448
453
449
@@ -530,8 +526,7 @@ public void dropDatabase(final String dbName) {
530
526
* databases obtained from it can no longer be used.
531
527
*/
532
528
public void close () {
533
- serverSessionPool .close ();
534
- cluster .close ();
529
+ delegate .close ();
535
530
if (cursorCleaningService != null ) {
536
531
cursorCleaningService .shutdownNow ();
537
532
}
@@ -764,11 +759,11 @@ private static ClusterSettings getClusterSettings(final List<ServerAddress> seed
764
759
}
765
760
766
761
Cluster getCluster () {
767
- return cluster ;
762
+ return delegate . getCluster () ;
768
763
}
769
764
770
765
ServerSessionPool getServerSessionPool () {
771
- return serverSessionPool ;
766
+ return delegate . getServerSessionPool () ;
772
767
}
773
768
774
769
Bytes .OptionHolder getOptionHolder () {
@@ -814,7 +809,7 @@ public void run() {
814
809
private void cleanCursors () {
815
810
ServerCursorAndNamespace cur ;
816
811
while ((cur = orphanedCursors .poll ()) != null ) {
817
- ReadWriteBinding binding = new SingleServerBinding (cluster , cur .serverCursor .getAddress ());
812
+ ReadWriteBinding binding = new SingleServerBinding (delegate . getCluster () , cur .serverCursor .getAddress ());
818
813
try {
819
814
ConnectionSource source = binding .getReadConnectionSource ();
820
815
try {
0 commit comments