public class LastRevRecoveryAgent
extends java.lang.Object
The recovery agent will only sweep documents for a given clusterId if the root document contains a sweep revision for the clusterId. A missing sweep revision for a clusterId indicates an upgrade from an earlier Oak version and a crash before the initial sweep finished. This is not the responsibility of the recovery agent. An initial sweep for an upgrade must either happen with the oak-run 'revisions' sweep command or on startup of an upgraded Oak instance.
Constructor and Description |
---|
LastRevRecoveryAgent(DocumentStore store,
RevisionContext context) |
LastRevRecoveryAgent(DocumentStore store,
RevisionContext revisionContext,
MissingLastRevSeeker seeker,
java.util.function.Consumer<java.lang.Integer> afterRecovery) |
Modifier and Type | Method and Description |
---|---|
java.lang.Iterable<java.lang.Integer> |
getRecoveryCandidateNodes()
Gets the _lastRev recovery candidate cluster nodes.
|
boolean |
isRecoveryNeeded()
Determines if any of the cluster node failed to renew its lease and
did not properly shutdown.
|
void |
performRecoveryIfNeeded() |
int |
recover(int clusterId)
Same as
recover(int, long) , but does not wait for ongoing
recovery. |
int |
recover(int clusterId,
long waitUntil)
Recover the correct _lastRev updates for potentially missing candidate
nodes.
|
int |
recover(java.lang.Iterable<NodeDocument> suspects,
int clusterId)
|
int |
recover(java.lang.Iterable<NodeDocument> suspects,
int clusterId,
boolean dryRun)
Recover the correct _lastRev updates for the given candidate nodes.
|
public LastRevRecoveryAgent(DocumentStore store, RevisionContext revisionContext, MissingLastRevSeeker seeker, java.util.function.Consumer<java.lang.Integer> afterRecovery)
public LastRevRecoveryAgent(DocumentStore store, RevisionContext context)
public int recover(int clusterId, long waitUntil) throws DocumentStoreException
clusterId
, this method will waitUntil
the given
time in milliseconds for the recovery to finish.
If recovery is performed for the clusterId as exposed by the revision
context passed to the constructor of this recovery agent, then this
method will put a deadline on how long recovery may take. The deadline
is the current lease end as read from the clusterNodes
collection
entry for the clusterId
to recover minus the
ClusterNodeInfo.DEFAULT_LEASE_FAILURE_MARGIN_MILLIS
. This method
will throw a DocumentStoreException
if the deadline is reached.
This method will return:
-1
when another cluster node is busy performing recovery
for the given clusterId
and the waitUntil
time is
reached.0
when no recovery was needed or this thread waited
for another cluster node to finish the recovery within the given
waitUntil
time.clusterId
- the cluster id for which the _lastRev are to be recoveredwaitUntil
- wait until this time is milliseconds for recovery of the
given clusterId
if another cluster node is
already performing the recovery.-1
if a timeout occurred
while waiting for an ongoing recovery by another cluster node.DocumentStoreException
- if the deadline is reached or some other
error occurs while reading from the underlying document store.public int recover(int clusterId) throws DocumentStoreException
recover(int, long)
, but does not wait for ongoing
recovery.clusterId
- the cluster id for which the _lastRev are to be recovered-1
if there is an ongoing
recovery by another cluster node.DocumentStoreException
- if the deadline is reached or some other
error occurs while reading from the underlying document store.public int recover(java.lang.Iterable<NodeDocument> suspects, int clusterId) throws DocumentStoreException
suspects
- the potential suspectsclusterId
- the cluster id for which _lastRev recovery neededDocumentStoreException
- if the deadline is reached or some other
error occurs while reading from the underlying document store.public int recover(java.lang.Iterable<NodeDocument> suspects, int clusterId, boolean dryRun) throws DocumentStoreException
clusterNodes
collection
entry for the clusterId
to recover minus the
ClusterNodeInfo.DEFAULT_LEASE_FAILURE_MARGIN_MILLIS
. This method
will throw a DocumentStoreException
if the deadline is reached.suspects
- the potential suspectsclusterId
- the cluster id for which _lastRev recovery neededdryRun
- if true
, this method will only perform a check
but not apply the changes to the _lastRev fields.dryRun
is set true and no document was changed.DocumentStoreException
- if the deadline is reached or some other
error occurs while reading from the underlying document store.public boolean isRecoveryNeeded()
public void performRecoveryIfNeeded()
public java.lang.Iterable<java.lang.Integer> getRecoveryCandidateNodes()
Copyright © 2012–2022 The Apache Software Foundation. All rights reserved.