pingidentity / ldapsdk

UnboundID LDAP SDK for Java
Other
334 stars 81 forks source link

Automatically reconnect to an LDAP server that was down using RoundRobinServerSet & LDAPConnectionPool #57

Open andreimoga opened 5 years ago

andreimoga commented 5 years ago

I'm using last version 4.0.9 and the scenario is like the following:

I have partially solved it by using PruneUnneededConnectionsLDAPConnectionPoolHealthCheck with minAvailableConnections = 1, but is not super nice. Extending LDAPConnectionPool is out of discussion because is a final class. Also I have implemented 2 different LDAPConnectionPoolHealthCheck but both are not super nice because of missing information about inuse connections or to many connections opened by probing all servers using createIfNecessary = true

dirmgr commented 5 years ago

The LDAP SDK doesn’t really try to monitor the health of the backend servers, so when a server goes down, it doesn’t keep checking it to see when it comes back up. As such, it’s not designed to do automatic rebalancing in this way, and we’re probably not going to add that feature. However, you can configure your connection pool so that it happens naturally within a time frame that you specify.

Whenever the LDAP SDK needs to establish a new connection, it will use the configured ServerSet to obtain it, and that connection will remain established until one of the following things happens:

In your case, you want to do two things:

If you set up the connection pool in this way, then the number of connections should be rebalanced within a period of time equal to the maximum connection age after both servers are available again. If you want this to happen more quickly, then you can use a lower maximum connection age.