Class LdapConfiguration.ContextConfiguration.PoolConfiguration

java.lang.Object
io.micronaut.security.ldap.configuration.LdapConfiguration.ContextConfiguration.PoolConfiguration
Enclosing class:
LdapConfiguration.ContextConfiguration

@ConfigurationProperties("pool") public static class LdapConfiguration.ContextConfiguration.PoolConfiguration extends Object
Bounds of the JNDI LDAP connection pool, applied when LdapConfiguration.ContextConfiguration.isPooled() is true. The pool is shared by the whole JVM: the values are applied as the com.sun.jndi.ldap.connect.pool.maxsize, com.sun.jndi.ldap.connect.pool.prefsize and com.sun.jndi.ldap.connect.pool.timeout system properties when the configuration is created. A value set here always wins. A value not set here keeps the system property if it is already set, for example on the command line, and otherwise falls back to the default. getConnectTimeout() is applied to the pooled manager context itself, as the com.sun.jndi.ldap.connect.timeout JNDI environment property, and bounds the wait for a connection when the pool is saturated.

The JDK reads these system properties once, when the first pooled JNDI LDAP connection of the JVM is opened. Values applied after that have no effect.

Since:
5.5.2
Author:
James Kleeh
  • Field Details

    • PREFIX

      public static final String PREFIX
      The configuration prefix.
      See Also:
    • DEFAULT_MAX_SIZE

      public static final int DEFAULT_MAX_SIZE
      The default maximum number of pooled connections per connection identity.
      See Also:
    • DEFAULT_PREF_SIZE

      public static final int DEFAULT_PREF_SIZE
      The default preferred number of pooled connections per connection identity.
      See Also:
    • DEFAULT_IDLE_TIMEOUT

      public static final Duration DEFAULT_IDLE_TIMEOUT
      The default time after which an idle pooled connection is closed.
    • DEFAULT_CONNECT_TIMEOUT

      public static final Duration DEFAULT_CONNECT_TIMEOUT
      The default time a login waits for a pooled connection when the pool is saturated.
  • Constructor Details

    • PoolConfiguration

      public PoolConfiguration()
  • Method Details

    • getMaxSize

      public @Nullable Integer getMaxSize()
      Returns:
      The maximum number of pooled connections per connection identity, or null to keep the com.sun.jndi.ldap.connect.pool.maxsize system property if set and otherwise use 20
    • setMaxSize

      public void setMaxSize(@Nullable Integer maxSize)
      Sets the maximum number of connections the pool keeps per connection identity (server, manager DN and password). Once reached, a login waits for a pooled connection to be released instead of opening a new one. 0 removes the bound, which lets a burst of login attempts exhaust the connections of the directory; a negative value is rejected. Default 20, unless the com.sun.jndi.ldap.connect.pool.maxsize system property is already set.
      Parameters:
      maxSize - The maximum pool size
    • getPrefSize

      public @Nullable Integer getPrefSize()
      Returns:
      The preferred number of pooled connections per connection identity, or null to keep the com.sun.jndi.ldap.connect.pool.prefsize system property if set and otherwise use 5
    • setPrefSize

      public void setPrefSize(@Nullable Integer prefSize)
      Sets the preferred number of connections the pool keeps per connection identity. Connections released above this number are closed rather than returned to the pool. A negative value is rejected. Default 5, unless the com.sun.jndi.ldap.connect.pool.prefsize system property is already set.
      Parameters:
      prefSize - The preferred pool size
    • getIdleTimeout

      public @Nullable Duration getIdleTimeout()
      Returns:
      The time after which an idle pooled connection is closed, or null to keep the com.sun.jndi.ldap.connect.pool.timeout system property if set and otherwise use 5 minutes
    • setIdleTimeout

      public void setIdleTimeout(@Nullable Duration idleTimeout)
      Sets the time after which an idle pooled connection is closed. 0 keeps idle connections open forever; a negative value is rejected. Default 5 minutes, unless the com.sun.jndi.ldap.connect.pool.timeout system property is already set.
      Parameters:
      idleTimeout - The idle timeout
    • getConnectTimeout

      public @Nullable Duration getConnectTimeout()
      Returns:
      The time a login waits for a pooled connection when the pool is saturated, or null for 10 seconds; always positive
    • setConnectTimeout

      public void setConnectTimeout(@Nullable Duration connectTimeout)
      Sets the time a login waits for a pooled connection to be released when the pool already holds max-size connections, and the time allowed to open a new pooled connection. Without it, the JDK waits indefinitely, so a hung directory operation holding every pooled connection would block every later login. Applied as the com.sun.jndi.ldap.connect.timeout JNDI environment property of the pooled manager context, unless LdapConfiguration.ContextConfiguration.getProperties() already sets that key. The JDK waits indefinitely for a value of 0 or less, so such a value is rejected. Default 10 seconds.
      Parameters:
      connectTimeout - The connect timeout