Package org.mockserver.log
Class MockServerEventLog
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.mock.listeners.MockServerEventLogNotifier
org.mockserver.log.MockServerEventLog
- Author:
- jamesdbloom
-
Constructor Summary
ConstructorsConstructorDescriptionMockServerEventLog(Configuration configuration, MockServerLogger mockServerLogger, Scheduler scheduler, boolean asynchronousEventProcessing) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclear(RequestDefinition requestDefinition) protected String[]longNumber of log events dropped because the disruptor ring buffer was full.voidimportRecordedRequestResponse(HttpRequest httpRequest, HttpResponse httpResponse) Re-inject a recorded request/response pair loaded from a persisted NDJSON archive back into the live event log so it is retrievable exactly like an in-memory recording (viaretrieveRecordedRequests/retrieveRequestResponsesand the derived export formats).voidreset()voidretrieveAllRequests(boolean matchingExpectationsOnly, Consumer<List<RequestDefinition>> listConsumer) voidretrieveAllRequests(List<String> expectationIds, Consumer<List<RequestAndExpectationId>> listConsumer) voidretrieveAlmostMatchedEntries(Consumer<List<LogEntry>> listConsumer) voidretrieveLogEntriesByCorrelationId(String correlationId, Consumer<List<LogEntry>> listConsumer) <T> voidretrieveLogEntriesInReverseForUI(RequestDefinition requestDefinition, Predicate<LogEntry> logEntryPredicate, Function<LogEntry, T> logEntryMapper, Consumer<Stream<T>> consumer) voidretrieveMessageLogEntries(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) voidretrieveMessageLogEntriesIncludingDeleted(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) voidretrieveRecordedExpectationLogEntries(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) voidretrieveRecordedExpectations(RequestDefinition requestDefinition, Consumer<List<Expectation>> listConsumer) voidretrieveRequestLogEntries(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) voidretrieveRequestResponseMessageLogEntries(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) voidretrieveRequestResponses(RequestDefinition requestDefinition, Consumer<List<LogEventRequestAndResponse>> listConsumer) voidretrieveRequests(List<String> expectationIds, Consumer<List<RequestDefinition>> listConsumer) voidretrieveRequests(ExpectationId expectationId, Consumer<List<RequestDefinition>> listConsumer) voidretrieveRequests(RequestDefinition requestDefinition, Consumer<List<RequestDefinition>> listConsumer) voidretrieveRequests(Verification verification, String logCorrelationId, Consumer<List<RequestDefinition>> listConsumer) voidretrieveUnmatchedRequests(int limit, Consumer<List<LogEntry>> listConsumer) Retrieves the most recent NO_MATCH_RESPONSE log entries (requests that hit the server and matched no expectation).voidsetRecordedRequestConsumer(Consumer<LogEntry> recordedRequestConsumer) Register a hook invoked once per recorded exchange (FORWARDED_REQUEST or EXPECTATION_RESPONSE) log entry, off the request-matching / forwarding hot path, so a recorded proxied or mocked exchange can be persisted to disk without coupling file I/O into this class.intsize()voidstop()verify(Verification verification) voidverify(Verification verification, int additionalRemoteMatchCount, Consumer<String> resultConsumer) Evaluate a request-count verification, addingadditionalRemoteMatchCountto this node's local match count before comparing against theVerificationTimes.voidverify(Verification verification, Consumer<String> resultConsumer) verify(VerificationSequence verification) voidverify(VerificationSequence verificationSequence, Consumer<String> resultConsumer) Methods inherited from class org.mockserver.mock.listeners.MockServerEventLogNotifier
getScheduler, listenerCount, notifyListeners, registerListener, stopNotifications, unregisterListenerMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
equals, hashCode, toString
-
Constructor Details
-
MockServerEventLog
public MockServerEventLog(Configuration configuration, MockServerLogger mockServerLogger, Scheduler scheduler, boolean asynchronousEventProcessing)
-
-
Method Details
-
add
-
size
public int size() -
getDroppedLogEventCount
public long getDroppedLogEventCount()Number of log events dropped because the disruptor ring buffer was full. A non-zero, growing value indicates the event log cannot keep up with the incoming load — increaseringBufferSizeor reduce log verbosity. Always available (independent of whether Prometheus metrics are enabled); also mirrored to themock_server_dropped_log_eventsPrometheus counter when metrics are enabled. -
setRecordedRequestConsumer
Register a hook invoked once per recorded exchange (FORWARDED_REQUEST or EXPECTATION_RESPONSE) log entry, off the request-matching / forwarding hot path, so a recorded proxied or mocked exchange can be persisted to disk without coupling file I/O into this class. The hook receives the entry with FULL (un-truncated) bodies becauseprocessLogEntry(org.mockserver.log.model.LogEntry)invokes it BEFORE applyingmaxLoggedBodyBytestruncation. -
importRecordedRequestResponse
Re-inject a recorded request/response pair loaded from a persisted NDJSON archive back into the live event log so it is retrievable exactly like an in-memory recording (viaretrieveRecordedRequests/retrieveRequestResponsesand the derived export formats). The entry is logged as a FORWARDED_REQUEST and markedLogEntry.setSkipRecordedRequestPersistence(boolean)so re-loading an archive is idempotent and never appends the same exchanges back to the (possibly same) file. -
stop
public void stop() -
reset
public void reset() -
clear
-
retrieveMessageLogEntries
public void retrieveMessageLogEntries(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) -
retrieveMessageLogEntriesIncludingDeleted
public void retrieveMessageLogEntriesIncludingDeleted(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) -
retrieveRequestLogEntries
public void retrieveRequestLogEntries(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) -
retrieveRequests
public void retrieveRequests(Verification verification, String logCorrelationId, Consumer<List<RequestDefinition>> listConsumer) -
retrieveAllRequests
public void retrieveAllRequests(boolean matchingExpectationsOnly, Consumer<List<RequestDefinition>> listConsumer) -
retrieveAllRequests
public void retrieveAllRequests(List<String> expectationIds, Consumer<List<RequestAndExpectationId>> listConsumer) -
retrieveRequests
public void retrieveRequests(RequestDefinition requestDefinition, Consumer<List<RequestDefinition>> listConsumer) -
retrieveRequests
public void retrieveRequests(ExpectationId expectationId, Consumer<List<RequestDefinition>> listConsumer) -
retrieveRequests
public void retrieveRequests(List<String> expectationIds, Consumer<List<RequestDefinition>> listConsumer) -
retrieveRequestResponseMessageLogEntries
public void retrieveRequestResponseMessageLogEntries(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) -
retrieveRequestResponses
public void retrieveRequestResponses(RequestDefinition requestDefinition, Consumer<List<LogEventRequestAndResponse>> listConsumer) -
retrieveRecordedExpectationLogEntries
public void retrieveRecordedExpectationLogEntries(RequestDefinition requestDefinition, Consumer<List<LogEntry>> listConsumer) -
retrieveRecordedExpectations
public void retrieveRecordedExpectations(RequestDefinition requestDefinition, Consumer<List<Expectation>> listConsumer) -
retrieveLogEntriesByCorrelationId
-
retrieveAlmostMatchedEntries
-
retrieveUnmatchedRequests
Retrieves the most recent NO_MATCH_RESPONSE log entries (requests that hit the server and matched no expectation). Results are ordered most-recent-first and limited.- Parameters:
limit- maximum number of entries to return (capped at 100)listConsumer- callback receiving the list of matching log entries
-
retrieveLogEntriesInReverseForUI
-
verify
-
verify
-
verify
public void verify(Verification verification, int additionalRemoteMatchCount, Consumer<String> resultConsumer) Evaluate a request-count verification, addingadditionalRemoteMatchCountto this node's local match count before comparing against theVerificationTimes.Used by the T1.9 cluster verify fan-in:
HttpStatesums the match count reported by every cluster peer's LOCAL log and passes the total remote count here, so a count-based verification behind a load balancer is evaluated against the fleet-wide total rather than only the traffic that reached this node.additionalRemoteMatchCountis0on the ordinary single-node / non-fan-in path (identical behaviour to before). Only applies to request verification; response-aware verification always receives0. -
verify
-
verify
-
fieldsExcludedFromEqualsAndHashCode
- Overrides:
fieldsExcludedFromEqualsAndHashCodein classObjectWithReflectiveEqualsHashCodeToString
-