java.lang.Object
org.elasticsearch.xpack.security.support.LogThrottle

public final class LogThrottle extends Object
Limits how often an action (such as emitting a log line) may run. Each instance tracks its own window.
  • Constructor Details

    • LogThrottle

      public LogThrottle(ThreadPool threadPool, org.elasticsearch.core.TimeValue period)
      Constructs a new instance using ThreadPool.relativeTimeInMillis() as the time source and TimeValue.millis() as the period.
  • Method Details

    • acquire

      public boolean acquire()
      Returns:
      true if the configured period has elapsed since the last true return (or if this is the first time the method has been called); updates the internal timestamp when returning true.

      This method is not thread safe; concurrent acquire calls may both observe the window as elapsed, or have other races. Use a single-caller pattern or external synchronization if a hard guarantee is required.