public class CommitRateLimiter extends java.lang.Object implements CommitHook
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 and Description |
---|
CommitRateLimiter() |
Modifier and Type | Method and 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 until
unblockCommits() 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.
|
public void blockCommits()
unblockCommits()
is called.public void unblockCommits()
public boolean getBlockCommits()
public void setDelay(long delay)
0
, any currently blocked commit will be unblocked.delay
- milliseconds@NotNull public @NotNull NodeState processCommit(NodeState before, NodeState after, CommitInfo info) throws CommitFailedException
CommitHook
processCommit
in interface CommitHook
before
- content tree before the commitafter
- content tree prepared for the commitinfo
- metadata associated with this commitCommitFailedException
- if the commit should be rejectedpublic void blockCommit() throws CommitFailedException
CommitFailedException
public void beforeNonBlocking()
public void afterNonBlocking()
public boolean isThreadBlocking()
Copyright © 2010 - 2020 Adobe. All Rights Reserved