Package com.unboundid.ldap.sdk
Class AsyncRequestID
java.lang.Object
com.unboundid.ldap.sdk.AsyncRequestID
- All Implemented Interfaces:
Serializable,Future<LDAPResult>
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class AsyncRequestID
extends Object
implements Serializable, Future<LDAPResult>
This class defines an object that provides information about a request that
was initiated asynchronously. It may be used to abandon or cancel the
associated request. This class also implements the
java.util.concurrent.Future interface, so it may be used in that
manner.
Example
The following example initiates an asynchronous modify operation and then attempts to abandon it:
Modification mod = new Modification(ModificationType.REPLACE,
"description", "This is the new description.");
ModifyRequest modifyRequest =
new ModifyRequest("dc=example,dc=com", mod);
AsyncRequestID asyncRequestID =
connection.asyncModify(modifyRequest, myAsyncResultListener);
// Assume that we've waited a reasonable amount of time but the modify
// hasn't completed yet so we'll try to abandon it.
connection.abandon(asyncRequestID);
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean mayInterruptIfRunning) Attempts to cancel the associated asynchronous operation operation.booleanIndicates whether the provided object is equal to this async request ID.get()Attempts to get the result for the associated operation, waiting if necessary for it to complete.Attempts to get the result for the associated operation, waiting if necessary for up to the specified length of time for the operation to complete.intRetrieves the message ID for the associated request.inthashCode()Retrieves a hash code for this async request ID.booleanIndicates whether an attempt has been made to cancel the associated operation before it completed.booleanisDone()Indicates whether the associated operation has completed, regardless of whether it completed normally, completed with an error, or was canceled before starting.toString()Retrieves a string representation of this async request ID.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Method Details
-
getMessageID
Retrieves the message ID for the associated request.- Returns:
- The message ID for the associated request.
-
cancel
Attempts to cancel the associated asynchronous operation operation. This will cause an abandon request to be sent to the server for the associated request, but because there is no response to an abandon operation then there is no way that we can determine whether the operation was actually abandoned.- Specified by:
cancelin interfaceFuture<LDAPResult>- Parameters:
mayInterruptIfRunning- Indicates whether to interrupt the thread running the associated task. This will be ignored.- Returns:
trueif an abandon request was sent to cancel the associated operation, orfalseif it was not possible to send an abandon request because the operation has already completed, because an abandon request has already been sent, or because an error occurred while trying to send the cancel request.
-
isCancelled
Indicates whether an attempt has been made to cancel the associated operation before it completed.- Specified by:
isCancelledin interfaceFuture<LDAPResult>- Returns:
trueif an attempt was made to cancel the operation, orfalseif no cancel attempt was made, or if the operation completed before it could be canceled.
-
isDone
Indicates whether the associated operation has completed, regardless of whether it completed normally, completed with an error, or was canceled before starting.- Specified by:
isDonein interfaceFuture<LDAPResult>- Returns:
trueif the associated operation has completed, or if an attempt has been made to cancel it, orfalseif the operation has not yet completed and no cancel attempt has been made.
-
get
Attempts to get the result for the associated operation, waiting if necessary for it to complete. Note that this method will differ from the behavior defined in thejava.util.concurrent.FutureAPI in that it will not wait forever. Rather, it will wait for no more than the length of time specified as the maximum response time defined in the connection options for the connection used to send the asynchronous request. This is necessary because the operation may have been abandoned or otherwise interrupted, or the associated connection may have become invalidated, in a way that the LDAP SDK cannot detect.- Specified by:
getin interfaceFuture<LDAPResult>- Returns:
- The result for the associated operation. If the operation has been canceled, or if no result has been received within the response timeout period, then a generated response will be returned.
- Throws:
InterruptedException- If the thread calling this method was interrupted before a result was received.
-
get
@NotNull public LDAPResult get(long timeout, @NotNull TimeUnit timeUnit) throws InterruptedException, TimeoutException Attempts to get the result for the associated operation, waiting if necessary for up to the specified length of time for the operation to complete.- Specified by:
getin interfaceFuture<LDAPResult>- Parameters:
timeout- The maximum length of time to wait for the response.timeUnit- The time unit for the providedtimeoutvalue.- Returns:
- The result for the associated operation. If the operation has been canceled, then a generated response will be returned.
- Throws:
InterruptedException- If the thread calling this method was interrupted before a result was received.TimeoutException- If a timeout was encountered before the result could be obtained.
-
hashCode
Retrieves a hash code for this async request ID. -
equals
Indicates whether the provided object is equal to this async request ID. -
toString
Retrieves a string representation of this async request ID.
-