Package com.mongodb.connection
Class ServerSettings.Builder
java.lang.Object
com.mongodb.connection.ServerSettings.Builder
- Enclosing class:
- ServerSettings
A builder for the settings.
-
Method Summary
Modifier and TypeMethodDescriptionaddServerListener
(ServerListener serverListener) Add a server listener.addServerMonitorListener
(ServerMonitorListener serverMonitorListener) Adds a server monitor listener.applyConnectionString
(ConnectionString connectionString) Takes the settings from the givenConnectionString
and applies them to the builderapplySettings
(ServerSettings serverSettings) Applies the serverSettings to the builderbuild()
Create a new ServerSettings from the settings applied to this builder.heartbeatFrequency
(long heartbeatFrequency, TimeUnit timeUnit) Sets the frequency that the cluster monitor attempts to reach each server.minHeartbeatFrequency
(long minHeartbeatFrequency, TimeUnit timeUnit) Sets the minimum heartbeat frequency.serverListenerList
(List<ServerListener> serverListeners) Sets the server listeners.serverMonitorListenerList
(List<ServerMonitorListener> serverMonitorListeners) Sets the server monitor listeners.
-
Method Details
-
applySettings
Applies the serverSettings to the builderNote: Overwrites all existing settings
- Parameters:
serverSettings
- the serverSettings- Returns:
- this
- Since:
- 3.7
-
heartbeatFrequency
Sets the frequency that the cluster monitor attempts to reach each server. The default value is 10 seconds.- Parameters:
heartbeatFrequency
- the heartbeat frequencytimeUnit
- the time unit- Returns:
- this
-
minHeartbeatFrequency
Sets the minimum heartbeat frequency. In the event that the driver has to frequently re-check a server's availability, it will wait at least this long since the previous check to avoid wasted effort. The default value is 500 milliseconds.- Parameters:
minHeartbeatFrequency
- the minimum heartbeat frequencytimeUnit
- the time unit- Returns:
- this
-
addServerListener
Add a server listener.- Parameters:
serverListener
- the non-null server listener- Returns:
- this
- Since:
- 3.3
-
serverListenerList
Sets the server listeners.- Parameters:
serverListeners
- list of server listeners- Returns:
- this
- Since:
- 4.5
-
addServerMonitorListener
Adds a server monitor listener.- Parameters:
serverMonitorListener
- the non-null server monitor listener- Returns:
- this
- Since:
- 3.3
-
serverMonitorListenerList
public ServerSettings.Builder serverMonitorListenerList(List<ServerMonitorListener> serverMonitorListeners) Sets the server monitor listeners.- Parameters:
serverMonitorListeners
- list of server monitor listeners- Returns:
- this
- Since:
- 4.5
-
applyConnectionString
Takes the settings from the givenConnectionString
and applies them to the builder- Parameters:
connectionString
- the connection string containing details of how to connect to MongoDB- Returns:
- this
- Since:
- 3.3
-
build
Create a new ServerSettings from the settings applied to this builder.- Returns:
- a ServerSettings with the given settings.
-