Added pause/resume sync to ClusterNode #236
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds three methods to
ClusterNode
:ClusterNode#pauseSync()
acquires thesyncLock
to prevent any new synchronizations from running. If synchronization is currently running or the lock is otherwise acquired by another thread this one will wait indefinitely or throw aClusterException
if the thread is interrupted.ClusterNode#pauseSync(long)
does the same as test request #1 but only waits the specified number of milliseconds to acquire the lock and returns true if the lock was acquired, otherwise false.ClusterNode#resumeSync()
releases the lock allowing the normal synchronization process to resume.One use case for this is performing a hot backup of a running node. We can pause synchronization to ensure this node does not try to update the index while we perform our backup action. Note this only handles updates coming into the cluster from other nodes -- you'd still have to make sure the local node isn't performing any of its own content/index updates. Incomplete in that regard but gets us part way there.
See https://issues.apache.org/jira/browse/JCR-5142