Class AuditStore

java.lang.Object
org.mockserver.mock.audit.AuditStore

public class AuditStore extends Object
Thread-safe, append-only, bounded ring buffer of AuditEntry records for control-plane mutations. Oldest entries are evicted once the store reaches its maximum capacity.

The singleton's initial capacity is read once from controlPlaneAuditMaxEntries at class initialization, but is NOT fixed for the process lifetime: setMaxSize(int) resizes the store live, and is invoked when controlPlaneAuditMaxEntries changes via PUT /mockserver/configuration. A package-visible constructor exists for unit tests that need an isolated, small-capacity instance.

  • Method Details

    • getInstance

      public static AuditStore getInstance()
    • setMaxSize

      public void setMaxSize(int maxSize)
      Resize the store. A SHRINK takes effect immediately: the oldest entries are discarded until the store fits the new capacity, rather than waiting for further audited mutations to push them out. Non-positive values are ignored (the existing capacity is retained), matching the constructor's treatment of a non-positive configured value.
      Parameters:
      maxSize - the new capacity
    • getMaxSize

      public int getMaxSize()
      The store's current capacity.
    • add

      public void add(AuditEntry entry)
    • getRecent

      public List<AuditEntry> getRecent(int limit)
      Returns up to limit most-recent entries, newest first.
    • clear

      public void clear()
    • size

      public int size()