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>,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 a
RepairJob 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
FieldsModifier and TypeFieldDescriptionfinal SharedContextfinal booleanRange to repairfinal booleanfinal RepairParallelismfinal booleanfinal PreviewKindfinal booleanfinal booleanfinal SessionStatefinal org.apache.cassandra.repair.RepairSession.SafeExecutorfinal SchedulerFields inherited from class org.apache.cassandra.utils.concurrent.AbstractFuture
CANCELLED, UNCANCELLABLE, UNSET -
Constructor Summary
ConstructorsConstructorDescriptionRepairSession(SharedContext ctx, Scheduler validationScheduler, TimeUUID parentRepairSession, CommonRange commonRange, String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, boolean repairPaxos, boolean paxosOnly, String... cfnames) Create new repair session. -
Method Summary
Modifier and TypeMethodDescriptionvoidconvict(InetAddressAndPort endpoint, double phi) Convict the specified endpoint.protected ExecutorPlusvoidforceShutdown(Throwable reason) clear all RepairJobs and terminate this session.getId()voidonIRStateChange(LocalSession session) voidonRemove(InetAddressAndPort endpoint) voidonRestart(InetAddressAndPort endpoint, EndpointState epState) Called whenever a node is restarted.ranges()voidstart(ExecutorPlus executor) Start RepairJob on given ColumnFamilies.voidsyncComplete(RepairJobDesc desc, Message<SyncResponse> message) Notify this session that sync completed/failed with givenSyncNodePair.voidvoidvoidvoidvalidationComplete(RepairJobDesc desc, Message<ValidationResponse> message) Receive merkle tree response or failed response fromendpointfor current repair job.Methods inherited from class org.apache.cassandra.utils.concurrent.AsyncFuture
await, awaitUntil, flatMap, mapMethods 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, trySuccessMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.cassandra.utils.concurrent.Future
await, awaitUninterruptibly, flatMap, rethrowIfFailed, sync, syncThrowUncheckedOnInterrupt, syncUninterruptiblyMethods inherited from interface org.apache.cassandra.gms.IEndpointStateChangeSubscriber
beforeChange, onAlive, onChange, onDead, onJoin
-
Field Details
-
state
-
parallelismDegree
-
pullRepair
public final boolean pullRepair -
isIncremental
public final boolean isIncrementalRange to repair -
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
-
validationScheduler
-
-
Constructor Details
-
Method Details
-
getId
-
ranges
-
endpoints
-
trackValidationCompletion
public void trackValidationCompletion(Pair<RepairJobDesc, InetAddressAndPort> key, ValidationTask task) -
trackSyncCompletion
public void trackSyncCompletion(Pair<RepairJobDesc, SyncNodePair> key, CompletableRemoteSyncTask task) -
validationComplete
Receive merkle tree response or failed response fromendpointfor current repair job.- Parameters:
desc- repair job descriptionmessage- containing the merkle trees or an error
-
syncComplete
Notify this session that sync completed/failed with givenSyncNodePair.- Parameters:
desc- synced repair jobmessage- nodes that completed sync and if they were successful
-
start
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
-
forceShutdown
clear all RepairJobs and terminate this session.- Parameters:
reason- Cause of error for shutdown
-
onRemove
- Specified by:
onRemovein interfaceIEndpointStateChangeSubscriber
-
onRestart
Description copied from interface:IEndpointStateChangeSubscriberCalled 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() == falseasstateis from before the restarted node is marked up.- Specified by:
onRestartin interfaceIEndpointStateChangeSubscriber
-
convict
Description copied from interface:IFailureDetectionEventListenerConvict the specified endpoint.- Specified by:
convictin interfaceIFailureDetectionEventListener- Parameters:
endpoint- endpoint to be convictedphi- the value of phi with with ep was convicted
-
onIRStateChange
- Specified by:
onIRStateChangein interfaceLocalSessions.Listener