Package org.ldaptive.transport.netty
Class HandleMap
java.lang.Object
org.ldaptive.transport.netty.HandleMap
Container for operation handles that are waiting on a response from the LDAP server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
Logger for this class.private final AtomicBoolean
Only one notification can occur at a time.private boolean
Whether this queue is currently accepting new handles.private final Map<Integer,
DefaultOperationHandle> Map of message IDs to their operation handle.private final Semaphore
Semaphore to throttle incoming requests.private static final int
If property is greater than zero, use the throttle semaphore.private static final String
Ldap netty transport system property.private static final Duration
Maximum time to wait for the throttle semaphore.private static final String
Ldap netty transport system property. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
InvokesDefaultOperationHandle.abandon()
for all handles that have sent a request but not received a response.private void
Attempt to acquire the throttle semaphore.void
clear()
Removes all operation handles from the queue.void
close()
Close the queue to new handles.get
(int id) Returns the operation handle for the supplied message id.handles()
Returns all the operation handles in the queue.boolean
isOpen()
Returns whether this handle map is open.void
notifyOperationHandles
(UnsolicitedNotification notification) Send the supplied notification to all handles waiting for a response.void
Notifies all operation handles in the queue that an exception has occurred.void
open()
Open this queue to receive new handles.put
(int id, DefaultOperationHandle handle) Puts the supplied operation handle into the queue if the supplied id doesn't already exist in the queue.private void
releaseThrottle
(int permits) Release permits on the throttle semaphore.remove
(int id) Removes the operation handle from the supplied message id.int
size()
Returns the size of this queue.toString()
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERLogger for this class. -
THROTTLE_REQUESTS_PROPERTY
Ldap netty transport system property.- See Also:
-
THROTTLE_TIMEOUT_PROPERTY
Ldap netty transport system property.- See Also:
-
THROTTLE_REQUESTS
private static final int THROTTLE_REQUESTSIf property is greater than zero, use the throttle semaphore. -
THROTTLE_TIMEOUT
Maximum time to wait for the throttle semaphore. Default is 60 seconds. -
pending
Map of message IDs to their operation handle. -
notificationLock
Only one notification can occur at a time. -
throttle
Semaphore to throttle incoming requests. -
open
private boolean openWhether this queue is currently accepting new handles.
-
-
Constructor Details
-
HandleMap
HandleMap()Creates a new handle map.
-
-
Method Details
-
open
public void open()Open this queue to receive new handles. -
close
public void close()Close the queue to new handles. -
isOpen
public boolean isOpen()Returns whether this handle map is open.- Returns:
- is open
-
get
Returns the operation handle for the supplied message id. Returns null if this queue is not open.- Parameters:
id
- message id- Returns:
- operation handle or null
-
remove
Removes the operation handle from the supplied message id. Returns null if this queue is not open.- Parameters:
id
- message id- Returns:
- operation handle or null
-
put
Puts the supplied operation handle into the queue if the supplied id doesn't already exist in the queue.- Parameters:
id
- message idhandle
- to put- Returns:
- null or existing operation handle for the id
- Throws:
LdapException
- if this queue is not open
-
handles
Returns all the operation handles in the queue.- Returns:
- all operation handles
-
size
public int size()Returns the size of this queue.- Returns:
- queue size
-
clear
public void clear()Removes all operation handles from the queue. -
acquireThrottle
Attempt to acquire the throttle semaphore. No-op if throttling is not enabled.- Throws:
LdapException
- if the semaphore cannot be acquired or the thread is interrupted
-
releaseThrottle
private void releaseThrottle(int permits) Release permits on the throttle semaphore. No-op if throttling is not enabled.- Parameters:
permits
- number of permits to release
-
abandonRequests
public void abandonRequests()InvokesDefaultOperationHandle.abandon()
for all handles that have sent a request but not received a response. This method removes all handles from the queue. -
notifyOperationHandles
Notifies all operation handles in the queue that an exception has occurred. SeeDefaultOperationHandle.exception(LdapException)
. This method removes all handles from the queue.- Parameters:
e
- exception to provides to handles
-
notifyOperationHandles
Send the supplied notification to all handles waiting for a response.- Parameters:
notification
- to send to response handles
-
toString
-