Class LifeCycle

java.lang.Object
org.mockserver.lifecycle.LifeCycle
All Implemented Interfaces:
Closeable, AutoCloseable, Stoppable
Direct Known Subclasses:
MockServer

public abstract class LifeCycle extends Object implements Stoppable
Author:
jamesdbloom
  • Field Details

    • mockServerLogger

      protected final MockServerLogger mockServerLogger
    • bossGroup

      protected final io.netty.channel.EventLoopGroup bossGroup
    • workerGroup

      protected final io.netty.channel.EventLoopGroup workerGroup
    • forwardClientGroup

      protected volatile io.netty.channel.EventLoopGroup forwardClientGroup
    • httpState

      protected final HttpState httpState
    • serverServerBootstrap

      protected io.netty.bootstrap.ServerBootstrap serverServerBootstrap
  • Constructor Details

  • Method Details

    • requestProcessingStarted

      public void requestProcessingStarted()
      Mark that a data-plane request has started processing. Must be paired with exactly one requestProcessingComplete() call when the response has been written.
    • requestProcessingComplete

      public void requestProcessingComplete()
      Mark that a data-plane request has finished (its response has been written or the connection has otherwise completed). Callers must guard against double-invocation; the counter is never allowed to go negative.
    • getRequestsInFlight

      public int getRequestsInFlight()
      Returns:
      the number of data-plane requests currently being processed
    • stopAsync

      public CompletableFuture<String> stopAsync()
    • stop

      public void stop()
      Specified by:
      stop in interface Stoppable
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getEventLoopGroup

      protected io.netty.channel.EventLoopGroup getEventLoopGroup()
    • getForwardClientEventLoopGroup

      protected io.netty.channel.EventLoopGroup getForwardClientEventLoopGroup()
      Returns:
      the dedicated event-loop group for the outbound forward/proxy (loopback) HTTP client, kept disjoint from the server worker group so a pooled channel reused inside a synchronous local callback is never pinned to a blocked server worker thread (see field javadoc).

      Created lazily on the first call (double-checked locking on forwardClientGroupLock) so a pure-mock server that never forwards never allocates it. The group is always a NEW group sized by clientNioEventLoopThreadCount — never the workerGroup — preserving the disjoint-group self-deadlock invariant documented on the field. If the server is already stopping when the first forward arrives, the group is created but immediately shut down so it can never leak past stopAsync() (its isShuttingDown() then makes NettyHttpClient.sendRequest() no-op cleanly); all creation and the stopAsync() teardown read/write the field under the same lock, so a first-forward racing a stop can never leak an un-terminated group.

    • getScheduler

      public Scheduler getScheduler()
    • isRunning

      public boolean isRunning()
    • getLocalPorts

      public List<Integer> getLocalPorts()
    • getPort

      @Deprecated public Integer getPort()
      Deprecated.
      use getLocalPort instead of getPort
    • getLocalPort

      public int getLocalPort()
    • bindServerPorts

      public List<Integer> bindServerPorts(List<Integer> requestedPortBindings)
    • startedServer

      protected void startedServer(List<Integer> ports)
    • registerListener

      public LifeCycle registerListener(ExpectationsListener expectationsListener)