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>
AFuturethat 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 ThrowablependingException
-
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 voidabort(Throwable t)voidacquirePartitionLockLazily()ListenableFuture<V>addListener(Runnable listener, Executor exec)Adds a listener and executor to the ListenableFuture.voidattachChannel(io.netty.channel.Channel channel, boolean reuseChannel)booleancancel(boolean force)voidcancelTimeouts()io.netty.channel.Channelchannel()voiddone()Terminate and if there is no exception, mark this Future as done and release the internal lock.Vget()Vget(long l, TimeUnit tu)AsyncHandler<V>getAsyncHandler()ChannelStategetChannelState()RequestgetCurrentRequest()longgetLastTouch()NettyRequestgetNettyRequest()ObjectgetPartitionKey()RealmgetProxyRealm()ProxyServergetProxyServer()RealmgetRealm()longgetStart()RequestgetTargetRequest()TimeoutsHoldergetTimeoutsHolder()UrigetUri()intincrementAndGetCurrentRedirectCount()booleanincrementRetryAndCheck()booleanisAndSetInAuth(boolean set)booleanisAndSetInProxyAuth(boolean inProxyAuth)booleanisCancelled()booleanisConnectAllowed()booleanisDone()booleanisDontWriteBodyBecauseExpectContinue()booleanisHeadersAlreadyWrittenOnContinue()booleanisInAuth()booleanisInProxyAuth()booleanisKeepAlive()booleanisReplayPossible()Return true if theFuturecan be recovered.booleanisReuseChannel()booleanisStreamConsumed()voidsetAsyncHandler(AsyncHandler<V> asyncHandler)voidsetChannelState(ChannelState channelState)voidsetConnectAllowed(boolean allowConnect)voidsetCurrentRequest(Request currentRequest)voidsetDontWriteBodyBecauseExpectContinue(boolean dontWriteBodyBecauseExpectContinue)voidsetHeadersAlreadyWrittenOnContinue(boolean headersAlreadyWrittenOnContinue)voidsetInAuth(boolean inAuth)voidsetInProxyAuth(boolean inProxyAuth)voidsetKeepAlive(boolean keepAlive)voidsetNettyRequest(NettyRequest nettyRequest)voidsetProxyRealm(Realm proxyRealm)voidsetRealm(Realm realm)voidsetReuseChannel(boolean reuseChannel)voidsetStreamConsumed(boolean streamConsumed)voidsetTargetRequest(Request targetRequest)voidsetTimeoutsHolder(TimeoutsHolder timeoutsHolder)ObjecttakePartitionKeyLock()CompletableFuture<V>toCompletableFuture()StringtoString()voidtouch()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:
isCancelledin interfaceFuture<V>
-
get
public V get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<V>- Throws:
InterruptedExceptionExecutionException
-
get
public V get(long l, TimeUnit tu) throws InterruptedException, TimeoutException, ExecutionException
- Specified by:
getin interfaceFuture<V>- Throws:
InterruptedExceptionTimeoutExceptionExecutionException
-
done
public void done()
Description copied from interface:ListenableFutureTerminate and if there is no exception, mark this Future as done and release the internal lock.- Specified by:
donein interfaceListenableFuture<V>
-
abort
public void abort(Throwable t)
Description copied from interface:ListenableFuture- Specified by:
abortin interfaceListenableFuture<V>- Parameters:
t- the exception
-
touch
public void touch()
Description copied from interface:ListenableFutureTouch the current instance to prevent external service to times out.- Specified by:
touchin interfaceListenableFuture<V>
-
addListener
public ListenableFuture<V> addListener(Runnable listener, Executor exec)
Description copied from interface:ListenableFutureAdds 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:
addListenerin 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:
toCompletableFuturein 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 theFuturecan 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
Futurecannot 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)
-
-