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 TypeMethodDescriptionvoid
The current thread finished running code that must not be throttled or blocked.void
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).void
void
Block any further commits untilunblockCommits()
is called.protected void
delay()
boolean
boolean
Check whether the current thread is non-blocking.@NotNull NodeState
processCommit
(NodeState before, NodeState after, CommitInfo info) Validates and/or modifies the given content change before it gets persisted.void
setDelay
(long delay) Number of milliseconds to delay commits going through this hook.void
Unblock 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:CommitHook
Validates and/or modifies the given content change before it gets persisted.- Specified by:
processCommit
in 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
-
delay
- 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
-