Class CommitRateLimiter

java.lang.Object
org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter
All Implemented Interfaces:
CommitHook

public class CommitRateLimiter extends Object implements CommitHook
This CommitHook can be used to block or delay commits for any length of time. As long as commits are blocked this hook throws a CommitFailedException.
  • Constructor Details

    • CommitRateLimiter

      public CommitRateLimiter()
  • Method Details

    • blockCommits

      public void blockCommits()
      Block any further commits until unblockCommits() is called.
    • unblockCommits

      public void unblockCommits()
      Unblock blocked commits.
    • getBlockCommits

      public boolean getBlockCommits()
    • setDelay

      public void setDelay(long delay)
      Number of milliseconds to delay commits going through this hook. If 0, any currently blocked commit will be unblocked.
      Parameters:
      delay - milliseconds
    • processCommit

      @NotNull public @NotNull NodeState processCommit(NodeState before, NodeState after, CommitInfo info) throws CommitFailedException
      Description copied from interface: CommitHook
      Validates and/or modifies the given content change before it gets persisted.
      Specified by:
      processCommit in interface CommitHook
      Parameters:
      before - content tree before the commit
      after - content tree prepared for the commit
      info - metadata associated with this commit
      Returns:
      content tree to be committed
      Throws:
      CommitFailedException - if the commit should be rejected
    • blockCommit

      public void blockCommit() throws CommitFailedException
      Throws:
      CommitFailedException
    • delay

      protected void delay() throws CommitFailedException
      Throws:
      CommitFailedException
    • beforeNonBlocking

      public void beforeNonBlocking()
      The current thread will now run code that must not be throttled or blocked, such as processing events (EventListener.onEvent is going to be called).
    • afterNonBlocking

      public void afterNonBlocking()
      The current thread finished running code that must not be throttled or blocked.
    • isThreadBlocking

      public boolean isThreadBlocking()
      Check whether the current thread is non-blocking.
      Returns:
      whether thread thread is non-blocking