MongoClientOptions.Builder addClusterListener(ClusterListener clusterListener)
Adds the given cluster listener.//添加給定的集群監聽器
MongoClientOptions.Builder addCommandListener(CommandListener commandListener)
Adds the given command listener.//添加給定的命令監聽器
MongoClientOptions.Builder addConnectionPoolListener(ConnectionPoolListener connectionPoolListener)
Adds the given connection pool listener.//添加給定的連接池偵聽器。
MongoClientOptions.Builder addServerListener(ServerListener serverListener)
Adds the given server listener.//添加給定的服務器偵聽器。
MongoClientOptions.Builder addServerMonitorListener(ServerMonitorListener serverMonitorListener)
Adds the given server monitor listener.//添加給定的服務器監視器偵聽器。
MongoClientOptions.Builder alwaysUseMBeans(boolean alwaysUseMBeans)
Sets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is Java 6 or greater.
//設置由驅動程序注冊的JMX bean是否應該始終是mbean,而不管VM是Java 6還是更大。
MongoClientOptions.Builder applicationName(String applicationName)
Sets the logical name of the application using this MongoClient.//設置MongoClient應用程序的邏輯名稱。
MongoClientOptions build()
Build an instance of MongoClientOptions.//構建一個MongoClientOptions 實例
MongoClientOptions.Builder codecRegistry(CodecRegistry codecRegistry)
Sets the codec registry//設置注冊表編解碼器
MongoClientOptions.Builder connectionsPerHost(int connectionsPerHost)
Sets the maximum number of connections per host.//設置每個主機的最大連接數。
MongoClientOptions.Builder connectTimeout(int connectTimeout)
Sets the connection timeout.//設置連接超時。
MongoClientOptions.Builder cursorFinalizerEnabled(boolean cursorFinalizerEnabled)
Sets whether cursor finalizers are enabled.//設置是否啟用游標終結器。
MongoClientOptions.Builder dbDecoderFactory(DBDecoderFactory dbDecoderFactory)
Sets the decoder factory.//設置集譯碼器工廠。
MongoClientOptions.Builder dbEncoderFactory(DBEncoderFactory dbEncoderFactory)
Sets the encoder factory.//設置編碼器工廠。
MongoClientOptions.Builder description(String description)
Sets the description.//設置描述。
MongoClientOptions.Builder heartbeatConnectTimeout(int connectTimeout)
Sets the connect timeout for connections used for the cluster heartbeat.//為用於集群心跳的連接設置連接超時。
MongoClientOptions.Builder heartbeatFrequency(int heartbeatFrequency)
Sets the heartbeat frequency.//設置心跳頻率。
MongoClientOptions.Builder heartbeatSocketTimeout(int socketTimeout)
Sets the socket timeout for connections used for the cluster heartbeat.//為用於集群心跳的連接設置套接字超時。
MongoClientOptions.Builder legacyDefaults()
Sets defaults to be what they are in MongoOptions.//設置默認設置為MongoOptions。
MongoClientOptions.Builder localThreshold(int localThreshold)
Sets the local threshold.//設置本地閾值。
MongoClientOptions.Builder maxConnectionIdleTime(int maxConnectionIdleTime)
Sets the maximum idle time for a pooled connection.//設置池連接的最大空閑時間。
MongoClientOptions.Builder maxConnectionLifeTime(int maxConnectionLifeTime)
Sets the maximum life time for a pooled connection.//設置池連接的最大生命時間。
MongoClientOptions.Builder maxWaitTime(int maxWaitTime)
Sets the maximum time that a thread will block waiting for a connection.//設置的最長時間,線程阻塞等待連接。
MongoClientOptions.Builder minConnectionsPerHost(int minConnectionsPerHost)
Sets the minimum number of connections per host.//設置每個主機的最小連接數。
MongoClientOptions.Builder minHeartbeatFrequency(int minHeartbeatFrequency)
Sets the minimum heartbeat frequency.//設置最小的心跳頻率。
MongoClientOptions.Builder readConcern(ReadConcern readConcern)
Sets the read concern.
MongoClientOptions.Builder readPreference(ReadPreference readPreference)
Sets the read preference.
MongoClientOptions.Builder requiredReplicaSetName(String requiredReplicaSetName)
Sets the required replica set name for the cluster.//為集群設置所需的副本集名稱。
MongoClientOptions.Builder serverSelectionTimeout(int serverSelectionTimeout)
Sets the server selection timeout in milliseconds, which defines how long the driver will wait for server selection to succeed before throwing an exception.//設置服務器選擇超時以毫秒為間隔,這定義了在拋出異常之前,驅動程序等待服務器選擇成功的時間。
MongoClientOptions.Builder socketFactory(SocketFactory socketFactory)
Sets the socket factory.//設置套接字工廠。
MongoClientOptions.Builder socketKeepAlive(boolean socketKeepAlive)
Deprecated. //默認為true
configuring keep-alive has been deprecated. It now defaults to true and disabling it is not recommended.
MongoClientOptions.Builder socketTimeout(int socketTimeout)
Sets the socket timeout.//設置套接字超時。
MongoClientOptions.Builder sslContext(SSLContext sslContext)
Sets the SSLContext to be used with SSL is enabled.//設置啟用SSL的SSL上下文。
MongoClientOptions.Builder sslEnabled(boolean sslEnabled)
Sets whether to use SSL.//設置是否使用 SSL。
MongoClientOptions.Builder sslInvalidHostNameAllowed(boolean sslInvalidHostNameAllowed)
Define whether invalid host names should be allowed.//定義是否允許使用無效的主機名。
MongoClientOptions.Builder threadsAllowedToBlockForConnectionMultiplier(int threadsAllowedToBlockForConnectionMultiplier)
Sets the multiplier for number of threads allowed to block waiting for a connection.//設置允許阻塞等待連接的線程數量的倍數。
MongoClientOptions.Builder writeConcern(WriteConcern writeConcern)
Sets the write concern.
常用配置信息:
MongoClientOptions.Builder connectionsPerHost(int connectionsPerHost)
Sets the maximum number of connections per host.//設置每個主機的最大連接數。
MongoClientOptions.Builder connectTimeout(int connectTimeout)
Sets the connection timeout.//設置連接超時。
MongoClientOptions.Builder maxConnectionIdleTime(int maxConnectionIdleTime)
Sets the maximum idle time for a pooled connection.//設置池連接的最大空閑時間。
MongoClientOptions.Builder maxConnectionLifeTime(int maxConnectionLifeTime)
Sets the maximum life time for a pooled connection.//設置池連接的最大生命時間。
MongoClientOptions.Builder maxWaitTime(int maxWaitTime)
Sets the maximum time that a thread will block waiting for a connection.//設置的最長時間,線程阻塞等待連接。
MongoClientOptions.Builder minConnectionsPerHost(int minConnectionsPerHost)
Sets the minimum number of connections per host.//設置每個主機的最小連接數。
MongoClientOptions.Builder socketTimeout(int socketTimeout)
Sets the socket timeout.//設置套接字超時。
MongoClientOptions.Builder threadsAllowedToBlockForConnectionMultiplier(int threadsAllowedToBlockForConnectionMultiplier)
Sets the multiplier for number of threads allowed to block waiting for a connection.//設置允許阻塞等待連接的線程數量的倍數。
