Package org.asynchttpclient.netty
Class NettyResponseFuture<V>
- java.lang.Object
-
- org.asynchttpclient.netty.NettyResponseFuture<V>
-
- Type Parameters:
V
- the result type
- All Implemented Interfaces:
Future<V>
,ListenableFuture<V>
public final class NettyResponseFuture<V> extends Object implements ListenableFuture<V>
AFuture
that can be used to track when an asynchronous HTTP request has been fully processed.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.asynchttpclient.ListenableFuture
ListenableFuture.CompletedFailure<T>
-
-
Field Summary
Fields Modifier and Type Field Description Throwable
pendingException
-
Constructor Summary
Constructors Constructor Description NettyResponseFuture(Request originalRequest, AsyncHandler<V> asyncHandler, NettyRequest nettyRequest, int maxRetry, ChannelPoolPartitioning connectionPoolPartitioning, ConnectionSemaphore connectionSemaphore, ProxyServer proxyServer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort(Throwable t)
void
acquirePartitionLockLazily()
ListenableFuture<V>
addListener(Runnable listener, Executor exec)
Adds a listener and executor to the ListenableFuture.void
attachChannel(io.netty.channel.Channel channel, boolean reuseChannel)
boolean
cancel(boolean force)
void
cancelTimeouts()
io.netty.channel.Channel
channel()
void
done()
Terminate and if there is no exception, mark this Future as done and release the internal lock.V
get()
V
get(long l, TimeUnit tu)
AsyncHandler<V>
getAsyncHandler()
ChannelState
getChannelState()
Request
getCurrentRequest()
long
getLastTouch()
NettyRequest
getNettyRequest()
Object
getPartitionKey()
Realm
getProxyRealm()
ProxyServer
getProxyServer()
Realm
getRealm()
long
getStart()
Request
getTargetRequest()
TimeoutsHolder
getTimeoutsHolder()
Uri
getUri()
int
incrementAndGetCurrentRedirectCount()
boolean
incrementRetryAndCheck()
boolean
isAndSetInAuth(boolean set)
boolean
isAndSetInProxyAuth(boolean inProxyAuth)
boolean
isCancelled()
boolean
isConnectAllowed()
boolean
isDone()
boolean
isDontWriteBodyBecauseExpectContinue()
boolean
isHeadersAlreadyWrittenOnContinue()
boolean
isInAuth()
boolean
isInProxyAuth()
boolean
isKeepAlive()
boolean
isReplayPossible()
Return true if theFuture
can be recovered.boolean
isReuseChannel()
boolean
isStreamConsumed()
void
setAsyncHandler(AsyncHandler<V> asyncHandler)
void
setChannelState(ChannelState channelState)
void
setConnectAllowed(boolean allowConnect)
void
setCurrentRequest(Request currentRequest)
void
setDontWriteBodyBecauseExpectContinue(boolean dontWriteBodyBecauseExpectContinue)
void
setHeadersAlreadyWrittenOnContinue(boolean headersAlreadyWrittenOnContinue)
void
setInAuth(boolean inAuth)
void
setInProxyAuth(boolean inProxyAuth)
void
setKeepAlive(boolean keepAlive)
void
setNettyRequest(NettyRequest nettyRequest)
void
setProxyRealm(Realm proxyRealm)
void
setRealm(Realm realm)
void
setReuseChannel(boolean reuseChannel)
void
setStreamConsumed(boolean streamConsumed)
void
setTargetRequest(Request targetRequest)
void
setTimeoutsHolder(TimeoutsHolder timeoutsHolder)
Object
takePartitionKeyLock()
CompletableFuture<V>
toCompletableFuture()
String
toString()
void
touch()
Touch the current instance to prevent external service to times out.
-
-
-
Field Detail
-
pendingException
public Throwable pendingException
-
-
Constructor Detail
-
NettyResponseFuture
public NettyResponseFuture(Request originalRequest, AsyncHandler<V> asyncHandler, NettyRequest nettyRequest, int maxRetry, ChannelPoolPartitioning connectionPoolPartitioning, ConnectionSemaphore connectionSemaphore, ProxyServer proxyServer)
-
-
Method Detail
-
takePartitionKeyLock
public Object takePartitionKeyLock()
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfaceFuture<V>
-
get
public V get() throws InterruptedException, ExecutionException
- Specified by:
get
in interfaceFuture<V>
- Throws:
InterruptedException
ExecutionException
-
get
public V get(long l, TimeUnit tu) throws InterruptedException, TimeoutException, ExecutionException
- Specified by:
get
in interfaceFuture<V>
- Throws:
InterruptedException
TimeoutException
ExecutionException
-
done
public void done()
Description copied from interface:ListenableFuture
Terminate and if there is no exception, mark this Future as done and release the internal lock.- Specified by:
done
in interfaceListenableFuture<V>
-
abort
public void abort(Throwable t)
Description copied from interface:ListenableFuture
- Specified by:
abort
in interfaceListenableFuture<V>
- Parameters:
t
- the exception
-
touch
public void touch()
Description copied from interface:ListenableFuture
Touch the current instance to prevent external service to times out.- Specified by:
touch
in interfaceListenableFuture<V>
-
addListener
public ListenableFuture<V> addListener(Runnable listener, Executor exec)
Description copied from interface:ListenableFuture
Adds a listener and executor to the ListenableFuture. The listener will be passed to the executor for execution when theFuture
's computation is complete.
Executor can benull
, in that case executor will be executed in the thread where completion happens.
There is no guaranteed ordering of execution of listeners, they may get called in the order they were added and they may get called out of order, but any listener added through this method is guaranteed to be called once the computation is complete.- Specified by:
addListener
in interfaceListenableFuture<V>
- Parameters:
listener
- the listener to run when the computation is complete.exec
- the executor to run the listener in.- Returns:
- this Future
-
toCompletableFuture
public CompletableFuture<V> toCompletableFuture()
- Specified by:
toCompletableFuture
in interfaceListenableFuture<V>
-
getUri
public Uri getUri()
-
getProxyServer
public ProxyServer getProxyServer()
-
cancelTimeouts
public void cancelTimeouts()
-
getTargetRequest
public Request getTargetRequest()
-
setTargetRequest
public void setTargetRequest(Request targetRequest)
-
getCurrentRequest
public Request getCurrentRequest()
-
setCurrentRequest
public void setCurrentRequest(Request currentRequest)
-
getNettyRequest
public NettyRequest getNettyRequest()
-
setNettyRequest
public void setNettyRequest(NettyRequest nettyRequest)
-
getAsyncHandler
public AsyncHandler<V> getAsyncHandler()
-
setAsyncHandler
public void setAsyncHandler(AsyncHandler<V> asyncHandler)
-
isKeepAlive
public boolean isKeepAlive()
-
setKeepAlive
public void setKeepAlive(boolean keepAlive)
-
incrementAndGetCurrentRedirectCount
public int incrementAndGetCurrentRedirectCount()
-
getTimeoutsHolder
public TimeoutsHolder getTimeoutsHolder()
-
setTimeoutsHolder
public void setTimeoutsHolder(TimeoutsHolder timeoutsHolder)
-
isInAuth
public boolean isInAuth()
-
setInAuth
public void setInAuth(boolean inAuth)
-
isAndSetInAuth
public boolean isAndSetInAuth(boolean set)
-
isInProxyAuth
public boolean isInProxyAuth()
-
setInProxyAuth
public void setInProxyAuth(boolean inProxyAuth)
-
isAndSetInProxyAuth
public boolean isAndSetInProxyAuth(boolean inProxyAuth)
-
getChannelState
public ChannelState getChannelState()
-
setChannelState
public void setChannelState(ChannelState channelState)
-
isStreamConsumed
public boolean isStreamConsumed()
-
setStreamConsumed
public void setStreamConsumed(boolean streamConsumed)
-
getLastTouch
public long getLastTouch()
-
isHeadersAlreadyWrittenOnContinue
public boolean isHeadersAlreadyWrittenOnContinue()
-
setHeadersAlreadyWrittenOnContinue
public void setHeadersAlreadyWrittenOnContinue(boolean headersAlreadyWrittenOnContinue)
-
isDontWriteBodyBecauseExpectContinue
public boolean isDontWriteBodyBecauseExpectContinue()
-
setDontWriteBodyBecauseExpectContinue
public void setDontWriteBodyBecauseExpectContinue(boolean dontWriteBodyBecauseExpectContinue)
-
isConnectAllowed
public boolean isConnectAllowed()
-
setConnectAllowed
public void setConnectAllowed(boolean allowConnect)
-
attachChannel
public void attachChannel(io.netty.channel.Channel channel, boolean reuseChannel)
-
channel
public io.netty.channel.Channel channel()
-
isReuseChannel
public boolean isReuseChannel()
-
setReuseChannel
public void setReuseChannel(boolean reuseChannel)
-
incrementRetryAndCheck
public boolean incrementRetryAndCheck()
-
isReplayPossible
public boolean isReplayPossible()
Return true if theFuture
can be recovered. There is some scenario where a connection can be closed by an unexpected IOException, and in some situation we can recover from that exception.- Returns:
- true if that
Future
cannot be recovered.
-
getStart
public long getStart()
-
getPartitionKey
public Object getPartitionKey()
-
acquirePartitionLockLazily
public void acquirePartitionLockLazily() throws IOException
- Throws:
IOException
-
getRealm
public Realm getRealm()
-
setRealm
public void setRealm(Realm realm)
-
getProxyRealm
public Realm getProxyRealm()
-
setProxyRealm
public void setProxyRealm(Realm proxyRealm)
-
-