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 aRepairJobthat 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 booleanisIncrementalRange to repairbooleanoptimiseStreamsRepairParallelismparallelismDegreebooleanpaxosOnlyPreviewKindpreviewKindbooleanpullRepairbooleanrepairPaxosSessionStatestateExecutorPlustaskExecutorSchedulervalidationScheduler-
Fields inherited from class org.apache.cassandra.utils.concurrent.AbstractFuture
CANCELLED, UNCANCELLABLE, UNSET
-
-
Constructor Summary
Constructors Constructor Description RepairSession(TimeUUID parentRepairSession, Scheduler validationScheduler, 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 voidconvict(InetAddressAndPort endpoint, double phi)Convict the specified endpoint.protected ExecutorPluscreateExecutor()java.util.Collection<InetAddressAndPort>endpoints()voidforceShutdown(java.lang.Throwable reason)clear all RepairJobs and terminate this session.TimeUUIDgetId()voidonIRStateChange(LocalSession session)voidonRemove(InetAddressAndPort endpoint)voidonRestart(InetAddressAndPort endpoint, EndpointState epState)Called whenever a node is restarted.java.util.Collection<Range<Token>>ranges()voidstart(ExecutorPlus executor)Start RepairJob on given ColumnFamilies.voidsyncComplete(RepairJobDesc desc, SyncNodePair nodes, boolean success, java.util.List<SessionSummary> summaries)Notify this session that sync completed/failed with givenSyncNodePair.voidterminate()voidtrackSyncCompletion(Pair<RepairJobDesc,SyncNodePair> key, CompletableRemoteSyncTask task)voidtrackValidationCompletion(Pair<RepairJobDesc,InetAddressAndPort> key, ValidationTask task)voidvalidationComplete(RepairJobDesc desc, InetAddressAndPort endpoint, MerkleTrees trees)Receive merkle tree response or failed response fromendpointfor 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 ExecutorPlus taskExecutor
-
optimiseStreams
public final boolean optimiseStreams
-
validationScheduler
public final Scheduler validationScheduler
-
-
Constructor Detail
-
RepairSession
public RepairSession(TimeUUID parentRepairSession, Scheduler validationScheduler, 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()
-
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, InetAddressAndPort endpoint, MerkleTrees trees)
Receive merkle tree response or failed response fromendpointfor current repair job.- Parameters:
desc- repair job descriptionendpoint- endpoint that sent merkle treetrees- calculated merkle trees, or null if validation failed
-
syncComplete
public void syncComplete(RepairJobDesc desc, SyncNodePair nodes, boolean success, java.util.List<SessionSummary> summaries)
Notify this session that sync completed/failed with givenSyncNodePair.- Parameters:
desc- synced repair jobnodes- nodes that completed syncsuccess- true if sync succeeded
-
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()
-
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:
onRemovein interfaceIEndpointStateChangeSubscriber
-
onRestart
public void onRestart(InetAddressAndPort endpoint, EndpointState epState)
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
public void convict(InetAddressAndPort endpoint, double phi)
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
public void onIRStateChange(LocalSession session)
- Specified by:
onIRStateChangein interfaceLocalSessions.Listener
-
-