Package org.apache.cassandra.repair
Class RepairSession
- java.lang.Object
-
- org.apache.cassandra.utils.concurrent.AbstractFuture<V>
-
- org.apache.cassandra.utils.concurrent.AsyncFuture<RepairSessionResult>
-
- org.apache.cassandra.repair.RepairSession
-
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<RepairSessionResult>
,io.netty.util.concurrent.Future<RepairSessionResult>
,java.util.concurrent.Future<RepairSessionResult>
,IEndpointStateChangeSubscriber
,IFailureDetectionEventListener
,LocalSessions.Listener
,Awaitable
,Future<RepairSessionResult>
public class RepairSession extends AsyncFuture<RepairSessionResult> implements IEndpointStateChangeSubscriber, IFailureDetectionEventListener, LocalSessions.Listener
Coordinates the (active) repair of a list of non overlapping token ranges. A given RepairSession repairs a set of replicas for a given set of ranges on a list of column families. For each of the column family to repair, RepairSession creates aRepairJob
that handles the repair of that CF. A given RepairJob has the 3 main phases:- Paxos repair: unfinished paxos operations in the range/keyspace/table are first completed
- Validation phase: the job requests merkle trees from each of the replica involves
(
ValidationTask
) and waits until all trees are received (in validationComplete()). - Synchronization phase: once all trees are received, the job compares each tree with all the others. If there is
difference between 2 trees, the differences between the 2 endpoints will be streamed with a
SyncTask
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.cassandra.utils.concurrent.Awaitable
Awaitable.AbstractAwaitable, Awaitable.AsyncAwaitable, Awaitable.Defaults, Awaitable.SyncAwaitable
-
-
Field Summary
Fields Modifier and Type Field Description SharedContext
ctx
boolean
isIncremental
Range to repairboolean
optimiseStreams
RepairParallelism
parallelismDegree
boolean
paxosOnly
PreviewKind
previewKind
boolean
pullRepair
boolean
repairPaxos
SessionState
state
org.apache.cassandra.repair.RepairSession.SafeExecutor
taskExecutor
Scheduler
validationScheduler
-
Fields inherited from class org.apache.cassandra.utils.concurrent.AbstractFuture
CANCELLED, UNCANCELLABLE, UNSET
-
-
Constructor Summary
Constructors Constructor Description RepairSession(SharedContext ctx, Scheduler validationScheduler, TimeUUID parentRepairSession, CommonRange commonRange, java.lang.String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, boolean repairPaxos, boolean paxosOnly, java.lang.String... cfnames)
Create new repair session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
convict(InetAddressAndPort endpoint, double phi)
Convict the specified endpoint.protected ExecutorPlus
createExecutor(SharedContext ctx)
java.util.Collection<InetAddressAndPort>
endpoints()
void
forceShutdown(java.lang.Throwable reason)
clear all RepairJobs and terminate this session.TimeUUID
getId()
void
onIRStateChange(LocalSession session)
void
onRemove(InetAddressAndPort endpoint)
void
onRestart(InetAddressAndPort endpoint, EndpointState epState)
Called whenever a node is restarted.java.util.Collection<Range<Token>>
ranges()
void
start(ExecutorPlus executor)
Start RepairJob on given ColumnFamilies.void
syncComplete(RepairJobDesc desc, Message<SyncResponse> message)
Notify this session that sync completed/failed with givenSyncNodePair
.void
terminate(java.lang.Throwable reason)
void
trackSyncCompletion(Pair<RepairJobDesc,SyncNodePair> key, CompletableRemoteSyncTask task)
void
trackValidationCompletion(Pair<RepairJobDesc,InetAddressAndPort> key, ValidationTask task)
void
validationComplete(RepairJobDesc desc, Message<ValidationResponse> message)
Receive merkle tree response or failed response fromendpoint
for current repair job.-
Methods inherited from class org.apache.cassandra.utils.concurrent.AsyncFuture
await, awaitUntil, flatMap, map
-
Methods inherited from class org.apache.cassandra.utils.concurrent.AbstractFuture
addCallback, addCallback, addCallback, addCallback, addCallback, addCallback, addListener, addListener, addListener, addListeners, await, awaitThrowUncheckedOnInterrupt, awaitThrowUncheckedOnInterrupt, awaitUninterruptibly, awaitUninterruptibly, awaitUntilThrowUncheckedOnInterrupt, awaitUntilUninterruptibly, cancel, cause, description, flatMap, get, get, getNow, getWhenDone, isCancellable, isCancelled, isDone, isSuccess, isUncancellable, map, map, notifyExecutor, removeListener, removeListeners, setUncancellable, setUncancellableExclusive, toString, tryFailure, trySuccess
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.utils.concurrent.Future
await, awaitUninterruptibly, flatMap, rethrowIfFailed, sync, syncThrowUncheckedOnInterrupt, syncUninterruptibly
-
Methods inherited from interface org.apache.cassandra.gms.IEndpointStateChangeSubscriber
beforeChange, onAlive, onChange, onDead, onJoin
-
-
-
-
Field Detail
-
state
public final SessionState state
-
parallelismDegree
public final RepairParallelism parallelismDegree
-
pullRepair
public final boolean pullRepair
-
isIncremental
public final boolean isIncremental
Range to repair
-
previewKind
public final PreviewKind previewKind
-
repairPaxos
public final boolean repairPaxos
-
paxosOnly
public final boolean paxosOnly
-
taskExecutor
public final org.apache.cassandra.repair.RepairSession.SafeExecutor taskExecutor
-
optimiseStreams
public final boolean optimiseStreams
-
ctx
public final SharedContext ctx
-
validationScheduler
public final Scheduler validationScheduler
-
-
Constructor Detail
-
RepairSession
public RepairSession(SharedContext ctx, Scheduler validationScheduler, TimeUUID parentRepairSession, CommonRange commonRange, java.lang.String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, boolean repairPaxos, boolean paxosOnly, java.lang.String... cfnames)
Create new repair session.- Parameters:
parentRepairSession
- the parent sessions idcommonRange
- ranges to repairkeyspace
- name of keyspaceparallelismDegree
- specifies the degree of parallelism when calculating the merkle treespullRepair
- true if the repair should be one way (from remote host to this host and only applicable between two hosts--see RepairOption)repairPaxos
- true if incomplete paxos operations should be completed as part of repairpaxosOnly
- true if we should only complete paxos operations, not run a normal repaircfnames
- names of columnfamilies
-
-
Method Detail
-
createExecutor
protected ExecutorPlus createExecutor(SharedContext ctx)
-
getId
public TimeUUID getId()
-
endpoints
public java.util.Collection<InetAddressAndPort> endpoints()
-
trackValidationCompletion
public void trackValidationCompletion(Pair<RepairJobDesc,InetAddressAndPort> key, ValidationTask task)
-
trackSyncCompletion
public void trackSyncCompletion(Pair<RepairJobDesc,SyncNodePair> key, CompletableRemoteSyncTask task)
-
validationComplete
public void validationComplete(RepairJobDesc desc, Message<ValidationResponse> message)
Receive merkle tree response or failed response fromendpoint
for current repair job.- Parameters:
desc
- repair job descriptionmessage
- containing the merkle trees or an error
-
syncComplete
public void syncComplete(RepairJobDesc desc, Message<SyncResponse> message)
Notify this session that sync completed/failed with givenSyncNodePair
.- Parameters:
desc
- synced repair jobmessage
- nodes that completed sync and if they were successful
-
start
public void start(ExecutorPlus executor)
Start RepairJob on given ColumnFamilies. This first validates if all replica are available, and if they are, creates RepairJobs and submit to run on given executor.- Parameters:
executor
- Executor to run validation
-
terminate
public void terminate(@Nullable java.lang.Throwable reason)
-
forceShutdown
public void forceShutdown(java.lang.Throwable reason)
clear all RepairJobs and terminate this session.- Parameters:
reason
- Cause of error for shutdown
-
onRemove
public void onRemove(InetAddressAndPort endpoint)
- Specified by:
onRemove
in interfaceIEndpointStateChangeSubscriber
-
onRestart
public void onRestart(InetAddressAndPort endpoint, EndpointState epState)
Description copied from interface:IEndpointStateChangeSubscriber
Called whenever a node is restarted. Note that there is no guarantee when that happens that the node was previously marked down. It will have only ifstate.isAlive() == false
asstate
is from before the restarted node is marked up.- Specified by:
onRestart
in interfaceIEndpointStateChangeSubscriber
-
convict
public void convict(InetAddressAndPort endpoint, double phi)
Description copied from interface:IFailureDetectionEventListener
Convict the specified endpoint.- Specified by:
convict
in interfaceIFailureDetectionEventListener
- Parameters:
endpoint
- endpoint to be convictedphi
- the value of phi with with ep was convicted
-
onIRStateChange
public void onIRStateChange(LocalSession session)
- Specified by:
onIRStateChange
in interfaceLocalSessions.Listener
-
-