Package org.ldaptive
Class LdapURLActivatorService
- java.lang.Object
-
- org.ldaptive.LdapURLActivatorService
-
public final class LdapURLActivatorService extends Object
Singleton which manages a single thread that periodically tests inactive LDAP URLs.
-
-
Field Summary
Fields Modifier and Type Field Description private static Duration
ACTIVATOR_PERIOD
How often to test inactive connections.private static String
ACTIVATOR_PERIOD_PROPERTY
Ldap activator period system property.private List<LdapURL>
inactiveUrls
List of inactive URLs to test.private static LdapURLActivatorService
INSTANCE
Instance of this singleton.private static Duration
STALE_PERIOD
Length of time to consider inactive connections stale.private static String
STALE_PERIOD_PROPERTY
Ldap activator stale period system property.
-
Constructor Summary
Constructors Modifier Constructor Description private
LdapURLActivatorService()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
activateIfStale(LdapURL url)
Inspects the supplied url to determine how long it has been awaiting activation.(package private) void
clear()
Removes all registered inactive URLs.List<LdapURL>
getInactiveUrls()
Returns the list of inactive urls.static LdapURLActivatorService
getInstance()
Returns the instance of this singleton.static Duration
getPeriod()
Returns the activator period.void
registerUrl(LdapURL url)
Registers an LDAP URL to be tested for activation.(package private) void
testInactiveUrls()
Tests each registered URL.
-
-
-
Field Detail
-
ACTIVATOR_PERIOD_PROPERTY
private static final String ACTIVATOR_PERIOD_PROPERTY
Ldap activator period system property.- See Also:
- Constant Field Values
-
STALE_PERIOD_PROPERTY
private static final String STALE_PERIOD_PROPERTY
Ldap activator stale period system property.- See Also:
- Constant Field Values
-
ACTIVATOR_PERIOD
private static final Duration ACTIVATOR_PERIOD
How often to test inactive connections. Default is 5 minutes.
-
STALE_PERIOD
private static final Duration STALE_PERIOD
Length of time to consider inactive connections stale. Default is 4 hours.
-
INSTANCE
private static final LdapURLActivatorService INSTANCE
Instance of this singleton.
-
-
Method Detail
-
getInstance
public static LdapURLActivatorService getInstance()
Returns the instance of this singleton.- Returns:
- LDAP URL activator service
-
getPeriod
public static Duration getPeriod()
Returns the activator period.- Returns:
- activator period
-
registerUrl
public void registerUrl(LdapURL url)
Registers an LDAP URL to be tested for activation. Once a URL becomes active it is automatically removed.- Parameters:
url
- that is inactive and should be tested to become active
-
getInactiveUrls
public List<LdapURL> getInactiveUrls()
Returns the list of inactive urls.- Returns:
- inactive urls
-
testInactiveUrls
void testInactiveUrls()
Tests each registered URL. Removes URLs that successfully activated.
-
activateIfStale
private void activateIfStale(LdapURL url)
Inspects the supplied url to determine how long it has been awaiting activation. For urls that have been attempting activation for a long period, activate them to potentially free the memory. URLs will return to this service if they are still in use and failing. SeeSTALE_PERIOD
- Parameters:
url
- to inspect
-
clear
void clear()
Removes all registered inactive URLs.
-
-