Class 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 a RepairJob that handles the repair of that CF. A given RepairJob has the 2 main phases:
    1. Validation phase: the job requests merkle trees from each of the replica involves (ValidationTask) and waits until all trees are received (in validationComplete()).
    2. 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.
    The job is done once all its SyncTasks are done (i.e. have either computed no differences or the streaming they started is done (syncComplete())). A given session will execute the first phase (validation phase) of each of it's job sequentially. In other words, it will start the first job and only start the next one once that first job validation phase is complete. This is done so that the replica only create one merkle tree per range at a time, which is our way to ensure that such creation starts roughly at the same time on every node (see CASSANDRA-2816). However the synchronization phases are allowed to run concurrently (with each other and with validation phases). A given RepairJob has 2 modes: either sequential or not (RepairParallelism). If sequential, it will requests merkle tree creation from each replica in sequence (though in that case we still first send a message to each node to flush and snapshot data so each merkle tree creation is still done on similar data, even if the actual creation is not done simulatneously). If not sequential, all merkle tree are requested in parallel. Similarly, if a job is sequential, it will handle one SymmetricSyncTask at a time, but will handle all of them in parallel otherwise.
    • Field Detail

      • parentRepairSession

        public final java.util.UUID parentRepairSession
      • keyspace

        public final java.lang.String keyspace
      • pullRepair

        public final boolean pullRepair
      • commonRange

        public final CommonRange commonRange
        Range to repair
      • isIncremental

        public final boolean isIncremental
      • 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 id
        id - this sessions id
        commonRange - ranges to repair
        keyspace - name of keyspace
        parallelismDegree - specifies the degree of parallelism when calculating the merkle trees
        pullRepair - 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

      • getId

        public java.util.UUID getId()
      • ranges

        public java.util.Collection<Range<Token>> ranges()
      • validationComplete

        public void validationComplete​(RepairJobDesc desc,
                                       InetAddressAndPort endpoint,
                                       MerkleTrees trees)
        Receive merkle tree response or failed response from endpoint for current repair job.
        Parameters:
        desc - repair job description
        endpoint - endpoint that sent merkle tree
        trees - 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 given SyncNodePair.
        Parameters:
        desc - synced repair job
        nodes - nodes that completed sync
        success - 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