Class ConnectionPoolSettings


  • public class ConnectionPoolSettings
    extends java.lang.Object
    All settings that relate to the pool of connections to a MongoDB server.
    Since:
    3.0
    • Constructor Detail

      • ConnectionPoolSettings

        public ConnectionPoolSettings()
      • ConnectionPoolSettings

        public ConnectionPoolSettings​(JsonObject json)
    • Method Detail

      • setMaxSize

        public ConnectionPoolSettings setMaxSize​(java.lang.Integer maxSize)

        The maximum number of connections allowed. Those connections will be kept in the pool when idle. Once the pool is exhausted, any operation requiring a connection will block waiting for an available connection.

        Default is 100.

        Parameters:
        maxSize - the maximum number of connections in the pool.
        Returns:
        this
      • getMaxSize

        public java.lang.Integer getMaxSize()

        The maximum number of connections allowed. Those connections will be kept in the pool when idle. Once the pool is exhausted, any operation requiring a connection will block waiting for an available connection.

        Default is 100.

        Returns:
        the maximum number of connections in the pool.
      • setMinSize

        public ConnectionPoolSettings setMinSize​(java.lang.Integer minSize)

        The minimum number of connections. Those connections will be kept in the pool when idle, and the pool will ensure that it contains at least this minimum number.

        Default is 0.

        Parameters:
        minSize - the minimum number of connections to have in the pool at all times.
        Returns:
        this
      • getMinSize

        public java.lang.Integer getMinSize()

        The minimum number of connections. Those connections will be kept in the pool when idle, and the pool will ensure that it contains at least this minimum number.

        Default is 0.

        Returns:
        the minimum number of connections to have in the pool at all times.
      • setMaxWaitTime

        public ConnectionPoolSettings setMaxWaitTime​(java.lang.Long maxWaitTime)

        The maximum time that a thread may wait for a connection to become available.

        Default is 2 minutes. A value of 0 means that it will not wait. A negative value means it will wait indefinitely.

        Parameters:
        maxWaitTime - the maximum amount of time to wait (in milliseconds)
        Returns:
        this
      • getMaxWaitTime

        public java.lang.Long getMaxWaitTime()

        The maximum time that a thread may wait for a connection to become available.

        Default is 2 minutes. A value of 0 means that it will not wait. A negative value means it will wait indefinitely.

        Returns:
        the maximum amount of time to wait in the given TimeUnits
      • setMaxConnectionLifeTime

        public ConnectionPoolSettings setMaxConnectionLifeTime​(java.lang.Long maxConnectionLifeTime)
        The maximum time a pooled connection can live for. A zero value indicates no limit to the life time. A pooled connection that has exceeded its life time will be closed and replaced when necessary by a new connection.
        Parameters:
        maxConnectionLifeTime - the maximum length of time a connection can live (in milliseconds)
        Returns:
        this
      • getMaxConnectionLifeTime

        public java.lang.Long getMaxConnectionLifeTime()
        The maximum time a pooled connection can live for. A zero value indicates no limit to the life time. A pooled connection that has exceeded its life time will be closed and replaced when necessary by a new connection.
        Returns:
        the maximum length of time a connection can live in the given TimeUnits
      • setMaxConnectionIdleTime

        public ConnectionPoolSettings setMaxConnectionIdleTime​(java.lang.Long maxConnectionIdleTime)
        The maximum idle time of a pooled connection. A zero value indicates no limit to the idle time. A pooled connection that has exceeded its idle time will be closed and replaced when necessary by a new connection.
        Parameters:
        maxConnectionIdleTime - the maximum time a connection can be unused (in milliseconds)
        Returns:
        this
      • getMaxConnectionIdleTime

        public java.lang.Long getMaxConnectionIdleTime()
        Returns the maximum idle time of a pooled connection. A zero value indicates no limit to the idle time. A pooled connection that has exceeded its idle time will be closed and replaced when necessary by a new connection.
        Returns:
        the maximum time a connection can be unused, in the given TimeUnits
      • setMaintenanceInitialDelay

        public ConnectionPoolSettings setMaintenanceInitialDelay​(java.lang.Long maintenanceInitialDelay)
        The period of time to wait before running the first maintenance job on the connection pool.
        Parameters:
        maintenanceInitialDelay - the time period to wait (in milliseconds)
        Returns:
        this
      • getMaintenanceInitialDelay

        public java.lang.Long getMaintenanceInitialDelay()
        Returns the period of time to wait before running the first maintenance job on the connection pool.
        Returns:
        the time period to wait in the given units
      • setMaintenanceFrequency

        public ConnectionPoolSettings setMaintenanceFrequency​(java.lang.Long maintenanceFrequency)
        The time period between runs of the maintenance job.
        Parameters:
        maintenanceFrequency - the time period between runs of the maintenance job (in milliseconds)
        Returns:
        this
      • getMaintenanceFrequency

        public java.lang.Long getMaintenanceFrequency()
        Returns the time period between runs of the maintenance job.
        Returns:
        the time period between runs of the maintainance job in the given units