com.ning.http.client.providers.netty
Class NettyResponseFuture<V>

java.lang.Object
  extended by com.ning.http.client.listenable.AbstractListenableFuture<V>
      extended by com.ning.http.client.providers.netty.NettyResponseFuture<V>
Type Parameters:
V -
All Implemented Interfaces:
ListenableFuture<V>, Future<V>

public final class NettyResponseFuture<V>
extends AbstractListenableFuture<V>

A Future that can be used to track when an asynchronous HTTP request has been fully processed.


Field Summary
static String MAX_RETRY
           
 
Constructor Summary
NettyResponseFuture(URI uri, Request request, AsyncHandler<V> asyncHandler, org.jboss.netty.handler.codec.http.HttpRequest nettyRequest, int requestTimeoutInMs, int idleConnectionTimeoutInMs, NettyAsyncHttpProvider asyncHttpProvider, ConnectionPoolKeyStrategy connectionPoolKeyStrategy, ProxyServer proxyServer)
           
 
Method Summary
 void abort(Throwable t)
          Abort the current processing, and propagate the Throwable to the AsyncHandler or Future
protected  void attachChannel(org.jboss.netty.channel.Channel channel)
           
protected  void attachChannel(org.jboss.netty.channel.Channel channel, boolean reuseChannel)
           
 boolean cancel(boolean force)
          
 void cancelTimeouts()
           
 boolean cannotBeReplay()
          Return true if the Future cannot be recovered.
protected  boolean canRetry()
           
protected  org.jboss.netty.channel.Channel channel()
           
 void content(V v)
          Set the content that will be returned by this instance
 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)
          
protected  boolean getAndSetAuth(boolean inDigestAuth)
           
 boolean getAndSetStatusReceived(boolean sr)
           
 boolean getAndSetWriteBody(boolean writeBody)
          Write the Request body
 boolean getAndSetWriteHeaders(boolean writeHeaders)
          Write the Request headers
protected  AsyncHandler<V> getAsyncHandler()
           
 SocketAddress getChannelRemoteAddress()
           
 ConnectionPoolKeyStrategy getConnectionPoolKeyStrategy()
           
protected  org.jboss.netty.handler.codec.http.HttpResponse getHttpResponse()
           
 long getIdleConnectionTimeoutInMs()
           
protected  boolean getKeepAlive()
           
 long getLastTouch()
           
 org.jboss.netty.handler.codec.http.HttpRequest getNettyRequest()
           
 ProxyServer getProxyServer()
           
protected  Request getRequest()
           
 long getRequestTimeoutInMs()
           
 long getStart()
           
protected  com.ning.http.client.providers.netty.NettyResponseFuture.STATE getState()
           
protected  URI getURI()
           
 boolean hasExpired()
          Is the Future still valid
protected  int incrementAndGetCurrentRedirectCount()
           
 boolean isCancelled()
          
 boolean isConnectAllowed()
           
 boolean isDone()
          
 boolean isIdleConnectionTimeoutReached()
           
protected  boolean isInAuth()
           
 boolean isRequestTimeoutReached()
           
protected  NettyAsyncHttpProvider provider()
           
protected  boolean reuseChannel()
           
 void setConnectAllowed(boolean allowConnect)
           
protected  void setHttpResponse(org.jboss.netty.handler.codec.http.HttpResponse httpResponse)
           
 void setIdleConnectionTimeoutReached()
           
protected  void setKeepAlive(boolean keepAlive)
           
protected  void setNettyRequest(org.jboss.netty.handler.codec.http.HttpRequest nettyRequest)
           
 void setRequest(Request request)
           
 void setRequestTimeoutReached()
           
 void setReuseChannel(boolean reuseChannel)
           
protected  void setState(com.ning.http.client.providers.netty.NettyResponseFuture.STATE state)
           
 void setTimeoutsHolder(TimeoutsHolder timeoutsHolder)
           
protected  void setURI(URI uri)
           
 String toString()
           
 void touch()
          Touch the current instance to prevent external service to times out.
 
Methods inherited from class com.ning.http.client.listenable.AbstractListenableFuture
addListener, runListeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_RETRY

public static final String MAX_RETRY
See Also:
Constant Field Values
Constructor Detail

NettyResponseFuture

public NettyResponseFuture(URI uri,
                           Request request,
                           AsyncHandler<V> asyncHandler,
                           org.jboss.netty.handler.codec.http.HttpRequest nettyRequest,
                           int requestTimeoutInMs,
                           int idleConnectionTimeoutInMs,
                           NettyAsyncHttpProvider asyncHttpProvider,
                           ConnectionPoolKeyStrategy connectionPoolKeyStrategy,
                           ProxyServer proxyServer)
Method Detail

getURI

protected URI getURI()

setURI

protected void setURI(URI uri)

getConnectionPoolKeyStrategy

public ConnectionPoolKeyStrategy getConnectionPoolKeyStrategy()

getProxyServer

public ProxyServer getProxyServer()

isDone

public boolean isDone()


isCancelled

public boolean isCancelled()


cancel

public boolean cancel(boolean force)


hasExpired

public boolean hasExpired()
Is the Future still valid

Returns:
true if response has expired and should be terminated.

setRequestTimeoutReached

public void setRequestTimeoutReached()

isRequestTimeoutReached

public boolean isRequestTimeoutReached()

setIdleConnectionTimeoutReached

public void setIdleConnectionTimeoutReached()

isIdleConnectionTimeoutReached

public boolean isIdleConnectionTimeoutReached()

setTimeoutsHolder

public void setTimeoutsHolder(TimeoutsHolder timeoutsHolder)

get

public V get()
      throws InterruptedException,
             ExecutionException

Throws:
InterruptedException
ExecutionException

cancelTimeouts

public void cancelTimeouts()

get

public V get(long l,
             TimeUnit tu)
      throws InterruptedException,
             TimeoutException,
             ExecutionException

Throws:
InterruptedException
TimeoutException
ExecutionException

done

public final void done()
Description copied from interface: ListenableFuture
Terminate and if there is no exception, mark this Future as done and release the internal lock.


abort

public final void abort(Throwable t)
Description copied from interface: ListenableFuture
Abort the current processing, and propagate the Throwable to the AsyncHandler or Future


content

public void content(V v)
Description copied from interface: ListenableFuture
Set the content that will be returned by this instance

Parameters:
v - the content that will be returned by this instance

getRequest

protected final Request getRequest()

getNettyRequest

public final org.jboss.netty.handler.codec.http.HttpRequest getNettyRequest()

setNettyRequest

protected final void setNettyRequest(org.jboss.netty.handler.codec.http.HttpRequest nettyRequest)

getAsyncHandler

protected final AsyncHandler<V> getAsyncHandler()

getKeepAlive

protected final boolean getKeepAlive()

setKeepAlive

protected final void setKeepAlive(boolean keepAlive)

getHttpResponse

protected final org.jboss.netty.handler.codec.http.HttpResponse getHttpResponse()

setHttpResponse

protected final void setHttpResponse(org.jboss.netty.handler.codec.http.HttpResponse httpResponse)

incrementAndGetCurrentRedirectCount

protected int incrementAndGetCurrentRedirectCount()

isInAuth

protected boolean isInAuth()

getAndSetAuth

protected boolean getAndSetAuth(boolean inDigestAuth)

getState

protected com.ning.http.client.providers.netty.NettyResponseFuture.STATE getState()

setState

protected void setState(com.ning.http.client.providers.netty.NettyResponseFuture.STATE state)

getAndSetStatusReceived

public boolean getAndSetStatusReceived(boolean sr)

touch

public void touch()
Touch the current instance to prevent external service to times out.


getLastTouch

public long getLastTouch()

getAndSetWriteHeaders

public boolean getAndSetWriteHeaders(boolean writeHeaders)
Write the Request headers


getAndSetWriteBody

public boolean getAndSetWriteBody(boolean writeBody)
Write the Request body


provider

protected NettyAsyncHttpProvider provider()

attachChannel

protected void attachChannel(org.jboss.netty.channel.Channel channel)

setReuseChannel

public void setReuseChannel(boolean reuseChannel)

isConnectAllowed

public boolean isConnectAllowed()

setConnectAllowed

public void setConnectAllowed(boolean allowConnect)

attachChannel

protected void attachChannel(org.jboss.netty.channel.Channel channel,
                             boolean reuseChannel)

channel

protected org.jboss.netty.channel.Channel channel()

reuseChannel

protected boolean reuseChannel()

canRetry

protected boolean canRetry()

getChannelRemoteAddress

public SocketAddress getChannelRemoteAddress()

setRequest

public void setRequest(Request request)

cannotBeReplay

public boolean cannotBeReplay()
Return true if the Future cannot 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()

getRequestTimeoutInMs

public long getRequestTimeoutInMs()

getIdleConnectionTimeoutInMs

public long getIdleConnectionTimeoutInMs()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All Rights Reserved.