Class CommitRateLimiter
java.lang.Object
org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe current thread finished running code that must not be throttled or blocked.voidThe current thread will now run code that must not be throttled or blocked, such as processing events (EventListener.onEvent is going to be called).voidvoidBlock any further commits untilunblockCommits()is called.booleanbooleanCheck whether the current thread is non-blocking.@NotNull NodeStateprocessCommit(NodeState before, NodeState after, CommitInfo info) Validates and/or modifies the given content change before it gets persisted.voidsetDelay(long delay) Number of milliseconds to delay commits going through this hook.voidUnblock blocked commits.
-
Constructor Details
-
CommitRateLimiter
public CommitRateLimiter()
-
-
Method Details
-
blockCommits
public void blockCommits()Block any further commits untilunblockCommits()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. If0, 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:CommitHookValidates and/or modifies the given content change before it gets persisted.- Specified by:
processCommitin interfaceCommitHook- Parameters:
before- content tree before the commitafter- content tree prepared for the commitinfo- metadata associated with this commit- Returns:
- content tree to be committed
- Throws:
CommitFailedException- if the commit should be rejected
-
blockCommit
- 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
-