Class HttpDestination

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.client.transport.HttpDestination
All Implemented Interfaces:
Destination, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle, org.eclipse.jetty.util.thread.Invocable, org.eclipse.jetty.util.thread.Sweeper.Sweepable

@ManagedObject public class HttpDestination extends org.eclipse.jetty.util.component.ContainerLifeCycle implements Destination, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.thread.Sweeper.Sweepable
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Callback

    org.eclipse.jetty.util.Callback.Completable, org.eclipse.jetty.util.Callback.Completing, org.eclipse.jetty.util.Callback.Nested

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable

    org.eclipse.jetty.util.thread.Invocable.Callable, org.eclipse.jetty.util.thread.Invocable.InvocationType, org.eclipse.jetty.util.thread.Invocable.ReadyTask, org.eclipse.jetty.util.thread.Invocable.Task

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING

    Fields inherited from interface org.eclipse.jetty.util.Callback

    NOOP

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    KEY

    Fields inherited from interface org.eclipse.jetty.util.thread.Invocable

    __nonBlocking
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new HTTP destination.
    HttpDestination(HttpClient client, Origin origin, boolean intrinsicallySecure)
    Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept(Connection connection)
     
     
    protected void
    createConnection(org.eclipse.jetty.util.Promise<Connection> promise)
     
    protected void
     
    protected void
     
    void
    dump(Appendable out, String indent)
     
    protected boolean
     
    void
     
    org.eclipse.jetty.io.ClientConnectionFactory
     
     
     
    org.eclipse.jetty.http.HttpField
     
     
     
    long
     
     
    int
     
     
    int
     
     
    boolean
     
    boolean
     
    void
    newConnection(org.eclipse.jetty.util.Promise<Connection> promise)
    Creates asynchronously a new, unpooled, Connection that will be returned at a later time through the given Promise.
    protected ConnectionPool
     
    protected Queue<HttpExchange>
     
    void
    release(Connection connection)
     
    boolean
    remove(Connection connection)
     
    boolean
    remove(HttpExchange exchange)
     
    void
     
    void
    Sends the given request to this destination.
    void
    send(HttpExchange exchange)
     
    protected SendFailure
    send(IConnection connection, HttpExchange exchange)
     
    boolean
     
    void
     
    boolean
     
     

    Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

    addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.util.Callback

    completeWith

    Methods inherited from interface org.eclipse.jetty.util.component.Container

    getCachedBeans, getEventListeners

    Methods inherited from interface org.eclipse.jetty.client.Destination

    newConnection

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dump, dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable

    Methods inherited from interface org.eclipse.jetty.util.thread.Invocable

    getInvocationType
  • Constructor Details

  • Method Details

    • accept

      public void accept(Connection connection)
    • stale

      public boolean stale()
    • sweep

      public boolean sweep()
      Specified by:
      sweep in interface org.eclipse.jetty.util.thread.Sweeper.Sweepable
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      Exception
    • newConnectionPool

      protected ConnectionPool newConnectionPool(HttpClient client)
    • newExchangeQueue

      protected Queue<HttpExchange> newExchangeQueue(HttpClient client)
    • isSecure

      public boolean isSecure()
      Specified by:
      isSecure in interface Destination
      Returns:
      whether the communication with the destination is secure
    • getHttpClient

      public HttpClient getHttpClient()
      Specified by:
      getHttpClient in interface Destination
      Returns:
      the HttpClient that manages this destination
    • getOrigin

      public Origin getOrigin()
      Specified by:
      getOrigin in interface Destination
      Returns:
      the origin of this destination
    • getHttpExchanges

      public Queue<HttpExchange> getHttpExchanges()
    • getProxy

      public ProxyConfiguration.Proxy getProxy()
      Specified by:
      getProxy in interface Destination
      Returns:
      the proxy associated with this destination, or null if there is no proxy
    • getClientConnectionFactory

      public org.eclipse.jetty.io.ClientConnectionFactory getClientConnectionFactory()
    • getScheme

      @ManagedAttribute(value="The destination scheme", readonly=true) public String getScheme()
    • getHost

      @ManagedAttribute(value="The destination host", readonly=true) public String getHost()
    • getPort

      @ManagedAttribute(value="The destination port", readonly=true) public int getPort()
    • getQueuedRequestCount

      @ManagedAttribute(value="The number of queued requests", readonly=true) public int getQueuedRequestCount()
    • getHostField

      public org.eclipse.jetty.http.HttpField getHostField()
    • getConnectionPool

      @ManagedAttribute(value="The connection pool", readonly=true) public ConnectionPool getConnectionPool()
      Specified by:
      getConnectionPool in interface Destination
      Returns:
      the connection pool associated with this destination
    • succeeded

      public void succeeded()
      Specified by:
      succeeded in interface org.eclipse.jetty.util.Callback
    • failed

      public void failed(Throwable x)
      Specified by:
      failed in interface org.eclipse.jetty.util.Callback
    • send

      public void send(Request request, Response.CompleteListener listener)
      Description copied from interface: Destination

      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 -> { ... });
       
      Specified by:
      send in interface Destination
      Parameters:
      request - the request to send to this destination
      listener - the listener that receives response events
    • send

      public void send(HttpExchange exchange)
    • enqueue

      protected boolean enqueue(Queue<HttpExchange> queue, HttpExchange exchange)
    • send

      public void send()
    • send

      protected SendFailure send(IConnection connection, HttpExchange exchange)
    • newConnection

      public void newConnection(org.eclipse.jetty.util.Promise<Connection> promise)
      Description copied from interface: Destination
      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);
       
      Specified by:
      newConnection in interface Destination
      Parameters:
      promise - the promise of a new, unpooled, Connection
    • createConnection

      protected void createConnection(org.eclipse.jetty.util.Promise<Connection> promise)
    • remove

      public boolean remove(HttpExchange exchange)
    • release

      public void release(Connection connection)
    • remove

      public boolean remove(Connection connection)
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Overrides:
      dump in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      IOException
    • asString

      public String asString()
    • getIdle

      @ManagedAttribute("For how long this destination has been idle in ms") public long getIdle()
    • isStale

      @ManagedAttribute("Whether this destinations is stale") public boolean isStale()
    • toString

      public String toString()
      Overrides:
      toString in class org.eclipse.jetty.util.component.AbstractLifeCycle