Package com.mongodb.internal.connection
Class AbstractMultiServerCluster
- java.lang.Object
-
- com.mongodb.internal.connection.AbstractMultiServerCluster
-
- All Implemented Interfaces:
Cluster,java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
DnsMultiServerCluster,MultiServerCluster
public abstract class AbstractMultiServerCluster extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes connections to the servers in the cluster.BsonTimestampgetClusterTime()Get the last seen cluster timeClusterDescriptiongetCurrentDescription()Get the current description of this cluster.ClusterDescriptiongetDescription()Get the description of this cluster.ClusterableServerFactorygetServerFactory()ClusterSettingsgetSettings()Gets the cluster settings with which this cluster was created.booleanisClosed()Whether all the servers in the cluster are closed or not.ServerselectServer(ServerSelector serverSelector)Get a MongoDB server that matches the criteria defined by the serverSelectorvoidselectServerAsync(ServerSelector serverSelector, SingleResultCallback<Server> callback)Asynchronously gets a MongoDB server that matches the criteria defined by the serverSelector.
-
-
-
Method Detail
-
close
public void close()
Description copied from interface:ClusterCloses connections to the servers in the cluster. After this is called, this cluster instance can no longer be used.
-
getClusterTime
public BsonTimestamp getClusterTime()
Description copied from interface:ClusterGet the last seen cluster time- Specified by:
getClusterTimein interfaceCluster- Returns:
- the last seen cluster time or null if not set
-
selectServer
public Server selectServer(ServerSelector serverSelector)
Description copied from interface:ClusterGet a MongoDB server that matches the criteria defined by the serverSelector- Specified by:
selectServerin interfaceCluster- Parameters:
serverSelector- a ServerSelector that defines how to select the required Server- Returns:
- a Server that meets the requirements
-
selectServerAsync
public void selectServerAsync(ServerSelector serverSelector, SingleResultCallback<Server> callback)
Description copied from interface:ClusterAsynchronously gets a MongoDB server that matches the criteria defined by the serverSelector.- Specified by:
selectServerAsyncin interfaceCluster- Parameters:
serverSelector- a ServerSelector that defines how to select the required Servercallback- the callback to invoke when the server is found or an error occurs
-
getDescription
public ClusterDescription getDescription()
Description copied from interface:ClusterGet the description of this cluster. This method will not return normally until the cluster type is known.- Specified by:
getDescriptionin interfaceCluster- Returns:
- a ClusterDescription representing the current state of the cluster
-
getSettings
public ClusterSettings getSettings()
Description copied from interface:ClusterGets the cluster settings with which this cluster was created.- Specified by:
getSettingsin interfaceCluster- Returns:
- the cluster settings
-
getServerFactory
public ClusterableServerFactory getServerFactory()
-
isClosed
public boolean isClosed()
Description copied from interface:ClusterWhether all the servers in the cluster are closed or not.
-
getCurrentDescription
public ClusterDescription getCurrentDescription()
Description copied from interface:ClusterGet the current description of this cluster.- Specified by:
getCurrentDescriptionin interfaceCluster- Returns:
- the current ClusterDescription representing the current state of the cluster.
-
-