Package org.apache.cassandra.repair
Class RepairSession
- java.lang.Object
-
- com.google.common.util.concurrent.internal.InternalFutureFailureAccess
-
- com.google.common.util.concurrent.AbstractFuture<RepairSessionResult>
-
- org.apache.cassandra.repair.RepairSession
-
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<RepairSessionResult>
,java.util.concurrent.Future<RepairSessionResult>
,IEndpointStateChangeSubscriber
,IFailureDetectionEventListener
,LocalSessions.Listener
public class RepairSession extends com.google.common.util.concurrent.AbstractFuture<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 2 main phases:- 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
.
-
-
Field Summary
Fields Modifier and Type Field Description CommonRange
commonRange
Range to repairboolean
isIncremental
java.lang.String
keyspace
boolean
optimiseStreams
RepairParallelism
parallelismDegree
java.util.UUID
parentRepairSession
PreviewKind
previewKind
boolean
pullRepair
com.google.common.util.concurrent.ListeningExecutorService
taskExecutor
-
Constructor Summary
Constructors Constructor Description RepairSession(java.util.UUID parentRepairSession, java.util.UUID id, CommonRange commonRange, java.lang.String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, 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 DebuggableThreadPoolExecutor
createExecutor()
java.util.Collection<InetAddressAndPort>
endpoints()
void
forceShutdown(java.lang.Throwable reason)
clear all RepairJobs and terminate this session.java.util.UUID
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(com.google.common.util.concurrent.ListeningExecutorService executor)
Start RepairJob on given ColumnFamilies.void
syncComplete(RepairJobDesc desc, SyncNodePair nodes, boolean success, java.util.List<SessionSummary> summaries)
Notify this session that sync completed/failed with givenSyncNodePair
.void
terminate()
void
trackSyncCompletion(Pair<RepairJobDesc,SyncNodePair> key, CompletableRemoteSyncTask task)
void
trackValidationCompletion(Pair<RepairJobDesc,InetAddressAndPort> key, ValidationTask task)
void
validationComplete(RepairJobDesc desc, InetAddressAndPort endpoint, MerkleTrees trees)
Receive merkle tree response or failed response fromendpoint
for current repair job.-
Methods inherited from class com.google.common.util.concurrent.AbstractFuture
addListener, afterDone, cancel, get, get, interruptTask, isCancelled, isDone, pendingToString, set, setException, setFuture, toString, tryInternalFastPathGetFailure, wasInterrupted
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.gms.IEndpointStateChangeSubscriber
beforeChange, onAlive, onChange, onDead, onJoin
-
-
-
-
Field Detail
-
parentRepairSession
public final java.util.UUID parentRepairSession
-
keyspace
public final java.lang.String keyspace
-
parallelismDegree
public final RepairParallelism parallelismDegree
-
pullRepair
public final boolean pullRepair
-
commonRange
public final CommonRange commonRange
Range to repair
-
isIncremental
public final boolean isIncremental
-
previewKind
public final PreviewKind previewKind
-
taskExecutor
public final com.google.common.util.concurrent.ListeningExecutorService taskExecutor
-
optimiseStreams
public final boolean optimiseStreams
-
-
Constructor Detail
-
RepairSession
public RepairSession(java.util.UUID parentRepairSession, java.util.UUID id, CommonRange commonRange, java.lang.String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, java.lang.String... cfnames)
Create new repair session.- Parameters:
parentRepairSession
- the parent sessions idid
- this 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)cfnames
- names of columnfamilies
-
-
Method Detail
-
createExecutor
protected DebuggableThreadPoolExecutor createExecutor()
-
getId
public java.util.UUID 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 fromendpoint
for 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(com.google.common.util.concurrent.ListeningExecutorService 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:
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
-
-