ActiveRepairService (apache-cassandra API)
Date: 2018-02-12

org.apache.cassandra.service

## Class ActiveRepairService

- java.lang.Object
- - org.apache.cassandra.service.ActiveRepairService

- All Implemented Interfaces:
    IEndpointStateChangeSubscriber, IFailureDetectionEventListener

      public class ActiveRepairService
      extends java.lang.Object
      implements IEndpointStateChangeSubscriber, IFailureDetectionEventListener

  ActiveRepairService is the starting point for manual "active" repairs. Each user triggered repair will correspond to one or multiple repair session, one for each token range to repair. On repair session might repair multiple column families. For each of those column families, the repair session will request merkle trees for each replica of the range being repaired, diff those trees upon receiving them, schedule the streaming ofthe parts to repair (based on the tree diffs) and wait for all those operation. See RepairSession for more details. The creation of a repair session is done through the submitRepairSession that returns a future on the completion of that session.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ActiveRepairService.ParentRepairSession` We keep a ParentRepairSession around for the duration of the entire repair, for example, on a 256 token vnode rf=3 cluster we would have 768 RepairSession but only one ParentRepairSession.
    `static class` | `ActiveRepairService.Status` Deprecated. this statuses are from the previous JMX notification service, which will be deprecated on 4.0. For statuses of the new notification service, see `StreamEvent.ProgressEvent`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ActiveRepairService` | `instance`
    `static CassandraVersion` | `SUPPORTS_GLOBAL_PREPARE_FLAG_VERSION`
    `static long` | `UNREPAIRED_SSTABLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ActiveRepairService(IFailureDetector failureDetector, Gossiper gossiper)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beforeChange(java.net.InetAddress endpoint, EndpointState currentState, ApplicationState newStateKey, VersionedValue newValue)`
    `void` | `convict(java.net.InetAddress ep, double phi)` Something has happened to a remote node - if that node is a coordinator, we mark the parent repair session id as failed.
    `java.util.Set<SSTableReader>` | `currentlyRepairing(java.util.UUID cfId, java.util.UUID parentRepairSession)`
    `com.google.common.util.concurrent.ListenableFuture<java.util.List<java.lang.Object>>` | `doAntiCompaction(java.util.UUID parentRepairSession, java.util.Collection<Range<Token>> successfulRanges)` Submit anti-compaction jobs to CompactionManager.
    `com.google.common.util.concurrent.ListenableFuture` | `finishParentSession(java.util.UUID parentSession, java.util.Set<java.net.InetAddress> neighbors, java.util.Collection<Range<Token>> successfulRanges)` Run final process of repair.
    `static java.util.Set<java.net.InetAddress>` | `getNeighbors(java.lang.String keyspaceName, java.util.Collection<Range<Token>> keyspaceLocalRanges, Range<Token> toRepair, java.util.Collection<java.lang.String> dataCenters, java.util.Collection<java.lang.String> hosts)` Return all of the neighbors with whom we share the provided range.
    `ActiveRepairService.ParentRepairSession` | `getParentRepairSession(java.util.UUID parentSessionId)`
    `void` | `handleMessage(java.net.InetAddress endpoint, RepairMessage message)`
    `void` | `onAlive(java.net.InetAddress endpoint, EndpointState state)`
    `void` | `onChange(java.net.InetAddress endpoint, ApplicationState state, VersionedValue value)`
    `void` | `onDead(java.net.InetAddress endpoint, EndpointState state)`
    `void` | `onJoin(java.net.InetAddress endpoint, EndpointState epState)` Use to inform interested parties about the change in the state for specified endpoint
    `void` | `onRemove(java.net.InetAddress endpoint)`
    `void` | `onRestart(java.net.InetAddress endpoint, EndpointState state)` Called whenever a node is restarted.
    `java.util.UUID` | `prepareForRepair(java.util.UUID parentRepairSession, java.net.InetAddress coordinator, java.util.Set<java.net.InetAddress> endpoints, RepairOption options, java.util.List<ColumnFamilyStore> columnFamilyStores)`
    `void` | `registerParentRepairSession(java.util.UUID parentRepairSession, java.net.InetAddress coordinator, java.util.List<ColumnFamilyStore> columnFamilyStores, java.util.Collection<Range<Token>> ranges, boolean isIncremental, boolean isGlobal)`
    `ActiveRepairService.ParentRepairSession` | `removeParentRepairSession(java.util.UUID parentSessionId)` called when the repair session is done - either failed or anticompaction has completed clears out any snapshots created by this repair
    `RepairSession` | `submitRepairSession(java.util.UUID parentRepairSession, Range<Token> range, java.lang.String keyspace, RepairParallelism parallelismDegree, java.util.Set<java.net.InetAddress> endpoints, long repairedAt, com.google.common.util.concurrent.ListeningExecutorService executor, java.lang.String... cfnames)` Requests repairs for the given keyspace and column families.
    `void` | `terminateSessions()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SUPPORTS_GLOBAL_PREPARE_FLAG_VERSION

          public static CassandraVersion SUPPORTS_GLOBAL_PREPARE_FLAG_VERSION

    - #### instance

          public static final ActiveRepairService instance

    - #### UNREPAIRED_SSTABLE

          public static final long UNREPAIRED_SSTABLE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ActiveRepairService

          public ActiveRepairService(IFailureDetector failureDetector,
                                     Gossiper gossiper)

  - ### Method Detail

    - #### submitRepairSession

          public RepairSession submitRepairSession(java.util.UUID parentRepairSession,
                                                   Range<Token> range,
                                                   java.lang.String keyspace,
                                                   RepairParallelism parallelismDegree,
                                                   java.util.Set<java.net.InetAddress> endpoints,
                                                   long repairedAt,
                                                   com.google.common.util.concurrent.ListeningExecutorService executor,
                                                   java.lang.String... cfnames)

      Requests repairs for the given keyspace and column families.
      Returns:
        Future for asynchronous call or null if there is no need to repair

    - #### terminateSessions

          public void terminateSessions()

    - #### getNeighbors

          public static java.util.Set<java.net.InetAddress> getNeighbors(java.lang.String keyspaceName,
                                                                         java.util.Collection<Range<Token>> keyspaceLocalRanges,
                                                                         Range<Token> toRepair,
                                                                         java.util.Collection<java.lang.String> dataCenters,
                                                                         java.util.Collection<java.lang.String> hosts)

      Return all of the neighbors with whom we share the provided range.
      Parameters:
        `keyspaceName` - keyspace to repair
        `keyspaceLocalRanges` - local-range for given keyspaceName
        `toRepair` - token to repair
        `dataCenters` - the data centers to involve in the repair
      Returns:
        neighbors with whom we share the provided range

    - #### prepareForRepair

          public java.util.UUID prepareForRepair(java.util.UUID parentRepairSession,
                                                 java.net.InetAddress coordinator,
                                                 java.util.Set<java.net.InetAddress> endpoints,
                                                 RepairOption options,
                                                 java.util.List<ColumnFamilyStore> columnFamilyStores)

    - #### registerParentRepairSession

          public void registerParentRepairSession(java.util.UUID parentRepairSession,
                                                  java.net.InetAddress coordinator,
                                                  java.util.List<ColumnFamilyStore> columnFamilyStores,
                                                  java.util.Collection<Range<Token>> ranges,
                                                  boolean isIncremental,
                                                  boolean isGlobal)

    - #### currentlyRepairing

          public java.util.Set<SSTableReader> currentlyRepairing(java.util.UUID cfId,
                                                                 java.util.UUID parentRepairSession)

    - #### finishParentSession

          public com.google.common.util.concurrent.ListenableFuture finishParentSession(java.util.UUID parentSession,
                                                                                        java.util.Set<java.net.InetAddress> neighbors,
                                                                                        java.util.Collection<Range<Token>> successfulRanges)

      Run final process of repair. This removes all resources held by parent repair session, after performing anti compaction if necessary.
      Parameters:
        `parentSession` - Parent session ID
        `neighbors` - Repair participants (not including self)
        `successfulRanges` - Ranges that repaired successfully

    - #### getParentRepairSession

          public ActiveRepairService.ParentRepairSession getParentRepairSession(java.util.UUID parentSessionId)

    - #### removeParentRepairSession

          public ActiveRepairService.ParentRepairSession removeParentRepairSession(java.util.UUID parentSessionId)

      called when the repair session is done - either failed or anticompaction has completed clears out any snapshots created by this repair
      Parameters:
        `parentSessionId` -
      Returns:

    - #### doAntiCompaction

          public com.google.common.util.concurrent.ListenableFuture<java.util.List<java.lang.Object>> doAntiCompaction(java.util.UUID parentRepairSession,
                                                                                                                       java.util.Collection<Range<Token>> successfulRanges)

      Submit anti-compaction jobs to CompactionManager. When all jobs are done, parent repair session is removed whether those are suceeded or not.
      Parameters:
        `parentRepairSession` - parent repair session ID
      Returns:
        Future result of all anti-compaction jobs.

    - #### handleMessage

          public void handleMessage(java.net.InetAddress endpoint,
                                    RepairMessage message)

    - #### onJoin

          public void onJoin(java.net.InetAddress endpoint,
                             EndpointState epState)

      Description copied from interface: `IEndpointStateChangeSubscriber`
      Use to inform interested parties about the change in the state for specified endpoint
      Specified by:
        `onJoin` in interface `IEndpointStateChangeSubscriber`
      Parameters:
        `endpoint` - endpoint for which the state change occurred.
        `epState` - state that actually changed for the above endpoint.

    - #### beforeChange

          public void beforeChange(java.net.InetAddress endpoint,
                                   EndpointState currentState,
                                   ApplicationState newStateKey,
                                   VersionedValue newValue)

      Specified by:
        `beforeChange` in interface `IEndpointStateChangeSubscriber`

    - #### onChange

          public void onChange(java.net.InetAddress endpoint,
                               ApplicationState state,
                               VersionedValue value)

      Specified by:
        `onChange` in interface `IEndpointStateChangeSubscriber`

    - #### onAlive

          public void onAlive(java.net.InetAddress endpoint,
                              EndpointState state)

      Specified by:
        `onAlive` in interface `IEndpointStateChangeSubscriber`

    - #### onDead

          public void onDead(java.net.InetAddress endpoint,
                             EndpointState state)

      Specified by:
        `onDead` in interface `IEndpointStateChangeSubscriber`

    - #### onRemove

          public void onRemove(java.net.InetAddress endpoint)

      Specified by:
        `onRemove` in interface `IEndpointStateChangeSubscriber`

    - #### onRestart

          public void onRestart(java.net.InetAddress endpoint,
                                EndpointState state)

      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 if `state.isAlive() == false` as `state` is from before the restarted node is marked up.
      Specified by:
        `onRestart` in interface `IEndpointStateChangeSubscriber`

    - #### convict

          public void convict(java.net.InetAddress ep,
                              double phi)

      Something has happened to a remote node - if that node is a coordinator, we mark the parent repair session id as failed. The fail marker is kept in the map for 24h to make sure that if the coordinator does not agree that the repair failed, we need to fail the entire repair session
      Specified by:
        `convict` in interface `IFailureDetectionEventListener`
      Parameters:
        `ep` - endpoint to be convicted
        `phi` - the value of phi with with ep was convicted

Copyright © 2018 The Apache Software Foundation