Package org.mockserver.lifecycle
Class LifeCycle
java.lang.Object
org.mockserver.lifecycle.LifeCycle
- All Implemented Interfaces:
Closeable,AutoCloseable,Stoppable
- Direct Known Subclasses:
MockServer
- Author:
- jamesdbloom
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final io.netty.channel.EventLoopGroupprotected io.netty.channel.EventLoopGroupprotected final HttpStateprotected final MockServerLoggerprotected io.netty.bootstrap.ServerBootstrapprotected final io.netty.channel.EventLoopGroup -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbindServerPorts(List<Integer> requestedPortBindings) voidclose()protected io.netty.channel.EventLoopGroupprotected io.netty.channel.EventLoopGroupintgetPort()Deprecated.use getLocalPort instead of getPortintbooleanregisterListener(ExpectationsListener expectationsListener) voidMark that a data-plane request has finished (its response has been written or the connection has otherwise completed).voidMark that a data-plane request has started processing.protected voidstartedServer(List<Integer> ports) voidstop()
-
Field Details
-
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
-
serverServerBootstrap
protected io.netty.bootstrap.ServerBootstrap serverServerBootstrap
-
-
Constructor Details
-
LifeCycle
-
-
Method Details
-
requestProcessingStarted
public void requestProcessingStarted()Mark that a data-plane request has started processing. Must be paired with exactly onerequestProcessingComplete()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
-
stop
public void stop() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
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 byclientNioEventLoopThreadCount— never theworkerGroup— 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 paststopAsync()(itsisShuttingDown()then makesNettyHttpClient.sendRequest()no-op cleanly); all creation and thestopAsync()teardown read/write the field under the same lock, so a first-forward racing a stop can never leak an un-terminated group.
-
getScheduler
-
isRunning
public boolean isRunning() -
getLocalPorts
-
getPort
Deprecated.use getLocalPort instead of getPort -
getLocalPort
public int getLocalPort() -
bindServerPorts
-
startedServer
-
registerListener
-