Class CommitRateLimiter
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter
-
- All Implemented Interfaces:
CommitHook
public class CommitRateLimiter extends java.lang.Object implements CommitHook
ThisCommitHook
can be used to block or delay commits for any length of time. As long as commits are blocked this hook throws aCommitFailedException
.
-
-
Constructor Summary
Constructors Constructor Description CommitRateLimiter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterNonBlocking()
The current thread finished running code that must not be throttled or blocked.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).void
blockCommit()
void
blockCommits()
Block any further commits untilunblockCommits()
is called.boolean
getBlockCommits()
boolean
isThreadBlocking()
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
unblockCommits()
Unblock blocked commits.
-
-
-
Method Detail
-
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
public void blockCommit() 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
-
-