Class AbstractHttpServerTransport

java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.http.AbstractHttpServerTransport
All Implemented Interfaces:
Closeable, AutoCloseable, LifecycleComponent, Releasable, HttpServerTransport, ReportingService<HttpInfo>

public abstract class AbstractHttpServerTransport extends AbstractLifecycleComponent implements HttpServerTransport
  • Field Details

  • Constructor Details

  • Method Details

    • recycler

      public Recycler<org.apache.lucene.util.BytesRef> recycler()
    • boundAddress

      public BoundTransportAddress boundAddress()
      Specified by:
      boundAddress in interface HttpServerTransport
    • info

      public HttpInfo info()
      Specified by:
      info in interface HttpServerTransport
      Specified by:
      info in interface ReportingService<HttpInfo>
    • stats

      public HttpStats stats()
      Specified by:
      stats in interface HttpServerTransport
    • bindServer

      protected void bindServer()
    • bind

      protected abstract HttpServerChannel bind(InetSocketAddress hostAddress) throws Exception
      Throws:
      Exception
    • doStart

      protected final void doStart()
      Description copied from class: AbstractLifecycleComponent
      Start this component. Typically that means doing things like launching background processes and registering listeners on other components. Other components have been initialized by this point, but may not yet be started.

      If this method throws an exception then the startup process will fail, but this component will not be stopped before it is closed.

      This method is called while synchronized on AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, although it may not be called at all if the startup process encountered some kind of fatal error, such as the failure of some other component to initialize or start.

      Specified by:
      doStart in class AbstractLifecycleComponent
    • startInternal

      protected abstract void startInternal()
    • doStop

      protected final void doStop()
      Gracefully shut down. If HttpTransportSettings.SETTING_HTTP_SERVER_SHUTDOWN_GRACE_PERIOD is zero, the default, then forcefully close all open connections immediately. Serially run through the following steps:
      1. Stop listening for new HTTP connections, which means no new HttpChannel are added to the httpChannels list. serverAcceptedChannel(HttpChannel) will close any new channels to ensure this is true.
      2. Close the HttpChannel after a new request completes on all existing channels.
      3. Close all idle channels.
      4. If grace period is set, wait for all httpChannels to close via 2 for up to the configured grace period, shutdownGracePeriodMillis. If all connections are closed before the expiration of the grace period, stop waiting early.
      5. Close all remaining open httpChannels even if requests are in flight.
      Specified by:
      doStop in class AbstractLifecycleComponent
    • doClose

      protected void doClose()
      Description copied from class: AbstractLifecycleComponent
      Close this component. Typically that means doing the reverse of whatever happened during initialization, such as releasing resources acquired there.

      This method is called while synchronized on AbstractLifecycleComponent.lifecycle. It is called once in the lifetime of a component. If the component was started then it will be stopped before it is closed, and once it is closed it will not be started or stopped.

      Specified by:
      doClose in class AbstractLifecycleComponent
    • stopInternal

      protected abstract void stopInternal()
      Called to tear down internal resources
    • onException

      public void onException(HttpChannel channel, Exception e)
    • onServerException

      protected static void onServerException(HttpServerChannel channel, Exception e)
    • serverAcceptedChannel

      protected void serverAcceptedChannel(HttpChannel httpChannel)
    • incomingRequest

      public void incomingRequest(HttpRequest httpRequest, HttpChannel httpChannel)
      This method handles an incoming http request.
      Parameters:
      httpRequest - that is incoming
      httpChannel - that received the http request
    • populatePerRequestThreadContext

      protected void populatePerRequestThreadContext(RestRequest restRequest, ThreadContext threadContext)
    • getThreadPool

      public ThreadPool getThreadPool()