Top Inners Fields Constructors Methods
org.eclipse.jetty.client.transport

public Class HttpDestination

extends ContainerLifeCycle
implements Destination, Callback, Dumpable, Sweepable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.thread.Sweeper.Sweepable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.thread.Invocable, org.eclipse.jetty.client.Destination
Annotations
@ManagedObject
Imports
java.io.IOException, java.nio.channels.AsynchronousCloseException, java.util.ArrayList, .Iterator, .Queue, java.util.concurrent.RejectedExecutionException, .TimeoutException, org.eclipse.jetty.client.Connection, .ConnectionPool, .Destination, .HttpClient, .Origin, .ProxyConfiguration, .Request, .Response, org.eclipse.jetty.http.HttpField, .HttpHeader, .HttpScheme, org.eclipse.jetty.io.ClientConnectionFactory, .CyclicTimeouts, org.eclipse.jetty.util.BlockingArrayQueue, .Callback, .HostPort, .NanoTime, .Promise, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.eclipse.jetty.util.component.ContainerLifeCycle, .Dumpable, .DumpableCollection, .LifeCycle, org.eclipse.jetty.util.ssl.SslContextFactory, org.eclipse.jetty.util.thread.AutoLock, .Scheduler, .Sweeper, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
HttpDestination.RequestTimeouts

Enforces the total timeout for exchanges that are still in the queue.

Field Summary

Modifier and TypeField and Description
private long
private final HttpClient
private final ClientConnectionFactory
private ConnectionPool
private final Queue<HttpExchange>
private final HttpField
private static final Logger
private final Origin
private final ProxyConfiguration.Proxy
private final HttpDestination.RequestTimeouts
private boolean
private final AutoLock

Constructor Summary

AccessConstructor and Description
public
HttpDestination(HttpClient client, Origin origin, boolean intrinsicallySecure)

Method Summary

Modifier and TypeMethod and Description
public void
abort(Throwable
the abort cause
cause
)

Aborts all the HttpExchanges queued in this destination.

public void
accept(Connection connection)

public String
protected void
protected void
doStart()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

protected void
doStop()

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.

protected boolean
public void
failed(Throwable
the reason for the operation failure
x
)

Overrides default org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

public ClientConnectionFactory
public ConnectionPool
public String
public HttpField
public HttpClient
public Queue<HttpExchange>
public long
public Origin
public int
public ProxyConfiguration.Proxy
public int
public String
public boolean
public boolean
public void
newConnection(Promise<Connection>
the promise of a new, unpooled, Connection
promise
)

Implements org.eclipse.jetty.client.Destination.newConnection.

Creates asynchronously a new, unpooled, Connection that will be returned at a later time through the given Promise.

protected ConnectionPool
protected Queue<HttpExchange>
private ClientConnectionFactory
private void
process(boolean create)

private boolean
process(Connection connection)

public void
release(Connection connection)

public boolean
remove(HttpExchange exchange)

public boolean
remove(Connection connection)

public void
send(Request
the request to send to this destination
request
,
Response.CompleteListener
the listener that receives response events
listener
)

Implements org.eclipse.jetty.client.Destination.send.

Sends the given request to this destination.

pack-priv void
send(HttpRequest request)

public void
send(HttpExchange exchange)

public void
send()

private void
send(boolean create)

protected SendFailure
send(IConnection connection, HttpExchange exchange)

public boolean
public void
succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

public boolean
public String
toString()

Overrides org.eclipse.jetty.util.component.AbstractLifeCycle.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jetty.util.component.ContainerLifeCycle:
addBeanaddBeanaddEventListeneraddManagedcontainsdestroydumpdumpdumpObjectsdumpStdErrgetBeangetBeansgetBeansgetContainedBeansgetContainedBeansisAutoisManagedisUnmanagedmanageremoveBeanremoveBeansremoveEventListenersetBeansstartstopunmanageupdateBeanupdateBeanupdateBeansupdateBeans

Field Detail

activeNanoTimeback to summary
private long activeNanoTime
clientback to summary
private final HttpClient client
connectionFactoryback to summary
private final ClientConnectionFactory connectionFactory
connectionPoolback to summary
private ConnectionPool connectionPool
exchangesback to summary
private final Queue<HttpExchange> exchanges
hostFieldback to summary
private final HttpField hostField
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.util.component.ContainerLifeCycle.LOG.

originback to summary
private final Origin origin
proxyback to summary
private final ProxyConfiguration.Proxy proxy
requestTimeoutsback to summary
private final HttpDestination.RequestTimeouts requestTimeouts
staleback to summary
private boolean stale
staleLockback to summary
private final AutoLock staleLock

Constructor Detail

HttpDestinationback to summary
public HttpDestination(HttpClient client, Origin origin, boolean intrinsicallySecure)

Method Detail

abortback to summary
public void abort(Throwable cause)

Aborts all the HttpExchanges queued in this destination.

Parameters
cause:Throwable

the abort cause

acceptback to summary
public void accept(Connection connection)
asStringback to summary
public String asString()
createConnectionback to summary
protected void createConnection(Promise<Connection> promise)
doStartback to summary
protected void doStart() throws Exception

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStart.

Starts the managed lifecycle beans in the order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStart.

If there was a problem starting. Will cause a transition to FAILED state

doStopback to summary
protected void doStop() throws Exception

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Doc from org.eclipse.jetty.util.component.ContainerLifeCycle.doStop.

Stops the managed lifecycle beans in the reverse order they were added.

Annotations
@Override
Exceptions
Exception:

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStop.

If there was a problem stopping. Will cause a transition to FAILED state

dumpback to summary
public void dump(Appendable out, String indent) throws IOException

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Doc from org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.

Parameters
out:Appendable

The appendable to dump to

indent:String

The indent to apply after any new lines.

Annotations
@Override
Exceptions
IOException:
if unable to write to Appendable
enqueueback to summary
protected boolean enqueue(Queue<HttpExchange> queue, HttpExchange exchange)
failedback to summary
public void failed(Throwable x)

Overrides default org.eclipse.jetty.util.Callback.failed.

Doc from org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

Parameters
x:Throwable

the reason for the operation failure

Annotations
@Override
getClientConnectionFactoryback to summary
public ClientConnectionFactory getClientConnectionFactory()
getConnectionPoolback to summary
public ConnectionPool getConnectionPool()

Implements org.eclipse.jetty.client.Destination.getConnectionPool.

Returns:ConnectionPool

Doc from org.eclipse.jetty.client.Destination.getConnectionPool.

the connection pool associated with this destination

Annotations
@ManagedAttribute:The connection pool
readonly:true
getHostback to summary
public String getHost()
Annotations
@ManagedAttribute:The destination host
readonly:true
getHostFieldback to summary
public HttpField getHostField()
getHttpClientback to summary
public HttpClient getHttpClient()

Implements org.eclipse.jetty.client.Destination.getHttpClient.

Returns:HttpClient

Doc from org.eclipse.jetty.client.Destination.getHttpClient.

the HttpClient that manages this destination

Annotations
@Override
getHttpExchangesback to summary
public Queue<HttpExchange> getHttpExchanges()
getIdleback to summary
public long getIdle()
Annotations
@ManagedAttribute:For how long this destination has been idle in ms
getOriginback to summary
public Origin getOrigin()

Implements org.eclipse.jetty.client.Destination.getOrigin.

Returns:Origin

Doc from org.eclipse.jetty.client.Destination.getOrigin.

the origin of this destination

Annotations
@Override
getPortback to summary
public int getPort()
Annotations
@ManagedAttribute:The destination port
readonly:true
getProxyback to summary
public ProxyConfiguration.Proxy getProxy()

Implements org.eclipse.jetty.client.Destination.getProxy.

Returns:ProxyConfiguration.Proxy

Doc from org.eclipse.jetty.client.Destination.getProxy.

the proxy associated with this destination, or null if there is no proxy

Annotations
@Override
getQueuedRequestCountback to summary
public int getQueuedRequestCount()
Annotations
@ManagedAttribute:The number of queued requests
readonly:true
getSchemeback to summary
public String getScheme()
Annotations
@ManagedAttribute:The destination scheme
readonly:true
isSecureback to summary
public boolean isSecure()

Implements org.eclipse.jetty.client.Destination.isSecure.

Returns:boolean

Doc from org.eclipse.jetty.client.Destination.isSecure.

whether the communication with the destination is secure

Annotations
@Override
isStaleback to summary
public boolean isStale()
Annotations
@ManagedAttribute:Whether this destinations is stale
newConnectionback to summary
public void newConnection(Promise<Connection> promise)

Implements org.eclipse.jetty.client.Destination.newConnection.

Doc from org.eclipse.jetty.client.Destination.newConnection.

Creates asynchronously a new, unpooled, Connection that will be returned at a later time through the given Promise.

Use FuturePromise to wait for the connection:

Destination destination = ...;
FuturePromise<Connection> futureConnection = new FuturePromise<>();
destination.newConnection(futureConnection);
Connection connection = futureConnection.get(5, TimeUnit.SECONDS);
Parameters
promise:Promise<Connection>

the promise of a new, unpooled, Connection

Annotations
@Override
newConnectionPoolback to summary
protected ConnectionPool newConnectionPool(HttpClient client)
newExchangeQueueback to summary
protected Queue<HttpExchange> newExchangeQueue(HttpClient client)
newSslClientConnectionFactoryback to summary
private ClientConnectionFactory newSslClientConnectionFactory(SslContextFactory.Client sslContextFactory, ClientConnectionFactory connectionFactory)
processback to summary
private void process(boolean create)
processback to summary
private boolean process(Connection connection)
releaseback to summary
public void release(Connection connection)
removeback to summary
public boolean remove(HttpExchange exchange)
removeback to summary
public boolean remove(Connection connection)
sendback to summary
public void send(Request request, Response.CompleteListener listener)

Implements org.eclipse.jetty.client.Destination.send.

Doc from org.eclipse.jetty.client.Destination.send.

Sends the given request to this destination.

You can use this method to send the request to a specific destination that may be different from the request authority.

For example when HttpClient is used in a proxy, it may receive a request with authority yourserver.com but the proxy logic may want to forward the request to a specific backend server, say backend01, therefore:

// Resolve the backend destination.
Origin backendOrigin = new Origin(backendScheme, "backend01", backendPort);
Destination backendDestination = httpClient.resolveDestination(backendOrigin);

// Create a request with the original authority.
Request request = httpClient.newRequest("https://yourserver.com/path");

// Send the request to the specific backend.
backendDestination.send(request, result -> { ... });
Parameters
request:Request

the request to send to this destination

listener:Response.CompleteListener

the listener that receives response events

Annotations
@Override
sendback to summary
pack-priv void send(HttpRequest request)
sendback to summary
public void send(HttpExchange exchange)
sendback to summary
public void send()
sendback to summary
private void send(boolean create)
sendback to summary
protected SendFailure send(IConnection connection, HttpExchange exchange)
staleback to summary
public boolean stale()
succeededback to summary
public void succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Doc from org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

Annotations
@Override
sweepback to summary
public boolean sweep()

Implements org.eclipse.jetty.util.thread.Sweeper.Sweepable.sweep.

Returns:boolean

Doc from org.eclipse.jetty.util.thread.Sweeper.Sweepable.sweep.

whether this resource should be swept

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.eclipse.jetty.util.component.AbstractLifeCycle.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jetty.client.transport back to summary

private Class HttpDestination.RequestTimeouts

extends CyclicTimeouts<HttpExchange>
Class Inheritance

Enforces the total timeout for exchanges that are still in the queue.

The total timeout for exchanges that are not in the destination queue is enforced in HttpConnection.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected Iterator<HttpExchange>
protected boolean
onExpired(HttpExchange
the entity that is expired
exchange
)

Implements abstract org.eclipse.jetty.io.CyclicTimeouts.onExpired.

Invoked during the iteration when the given entity is expired.

Inherited from org.eclipse.jetty.io.CyclicTimeouts:
destroyschedule

Constructor Detail

RequestTimeoutsback to summary
private RequestTimeouts(Scheduler scheduler)

Method Detail

iteratorback to summary
protected Iterator<HttpExchange> iterator()

Implements abstract org.eclipse.jetty.io.CyclicTimeouts.iterator.

Returns:Iterator<HttpExchange>

Doc from org.eclipse.jetty.io.CyclicTimeouts.iterator.

the entities to iterate over when this instance expires

Annotations
@Override
onExpiredback to summary
protected boolean onExpired(HttpExchange exchange)

Implements abstract org.eclipse.jetty.io.CyclicTimeouts.onExpired.

Doc from org.eclipse.jetty.io.CyclicTimeouts.onExpired.

Invoked during the iteration when the given entity is expired.

This method may be invoked multiple times, and even concurrently, for the same expirable entity and therefore the expiration of the entity, if any, should be an idempotent action.

When false is returned, the implementation should adjust the Expirable expiration, so that a call to Expirable#getExpireNanoTime() after this method has returned yields a new expiration nanoTime.

Parameters
exchange:HttpExchange

the entity that is expired

Returns:boolean

whether the entity should be removed from the iterator via Iterator#remove()

Annotations
@Override