Class CommitRateLimiter

  • All Implemented Interfaces:
    CommitHook

    public class CommitRateLimiter
    extends java.lang.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 Detail

      • CommitRateLimiter

        public CommitRateLimiter()
    • Method Detail

      • 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
      • 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