Package org.apache.cassandra.service
Class ActiveRepairService
java.lang.Object
org.apache.cassandra.service.ActiveRepairService
- All Implemented Interfaces:
IEndpointStateChangeSubscriber,IFailureDetectionEventListener,ActiveRepairServiceMBean
public class ActiveRepairService
extends Object
implements IEndpointStateChangeSubscriber, IFailureDetectionEventListener, ActiveRepairServiceMBean
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 ClassesModifier and TypeClassDescriptionstatic classstatic classWe 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 enumstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal SharedContextstatic final TimeUUIDfinal ExecutorPlusstatic final longFields inherited from interface org.apache.cassandra.service.ActiveRepairServiceMBean
MBEAN_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort(Predicate<ActiveRepairService.ParentRepairSession> predicate, String message) Remove any parent repair sessions matching predicatevoidbeforeChange(InetAddressAndPort endpoint, EndpointState currentState, ApplicationState newStateKey, VersionedValue newValue) voidcleanUp(TimeUUID parentRepairSession, Set<InetAddressAndPort> endpoints) Send Verb.CLEANUP_MSG to the given endpoints.cleanupPending(List<String> schemaArgs, String rangeString, boolean force) voidvoidconvict(InetAddressAndPort 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.coordinator(TimeUUID id) voidfailSession(String session, boolean force) intdoublegetNeighbors(String keyspaceName, Iterable<Range<Token>> keyspaceLocalRanges, Range<Token> toRepair, Collection<String> dataCenters, Collection<String> hosts) Return all of the neighbors with whom we share the provided range.getParentRepairSession(TimeUUID parentSessionId) We assume when calling this method that a parent session for the provided identifier exists, and that session is still in progress.intgetPendingStats(List<String> schemaArgs, String rangeString) intintDeprecated.See CASSANDRA-17668intDeprecated.See CASSANDRA-15234intgetRepairStats(List<String> schemaArgs, String rangeString) getRepairStatus(Integer cmd) getSessions(boolean all, String rangesStr) booleanvoidhandleMessage(Message<? extends RepairMessage> message) static ActiveRepairServiceinstance()voidonAlive(InetAddressAndPort endpoint, EndpointState state) voidonChange(InetAddressAndPort endpoint, ApplicationState state, VersionedValue value) voidonDead(InetAddressAndPort endpoint, EndpointState state) voidonJoin(InetAddressAndPort endpoint, EndpointState epState) Use to inform interested parties about the change in the state for specified endpointvoidonRemove(InetAddressAndPort endpoint) voidonRestart(InetAddressAndPort endpoint, EndpointState state) Called whenever a node is restarted.intintEach ongoing repair (incremental and non-incremental) is represented by aActiveRepairService.ParentRepairSessionentry in theActiveRepairServicecache.participate(TimeUUID id) Future<?>prepareForRepair(TimeUUID parentRepairSession, InetAddressAndPort coordinator, Set<InetAddressAndPort> endpoints, RepairOption options, boolean isForcedRepair, List<ColumnFamilyStore> columnFamilyStores) voidrecordRepairStatus(int cmd, ActiveRepairService.ParentRepairStatus parentRepairStatus, List<String> messages) voidregister(CoordinatorState state) booleanregister(ParticipateState state) voidregisterParentRepairSession(TimeUUID parentRepairSession, InetAddressAndPort coordinator, List<ColumnFamilyStore> columnFamilyStores, Collection<Range<Token>> ranges, boolean isIncremental, long repairedAt, boolean isGlobal, PreviewKind previewKind) removeParentRepairSession(TimeUUID parentSessionId) called when the repair session is done - either failed or anticompaction has completedstatic ExecutorPlusFuture<?>repairPaxosForTopologyChange(String ksName, Collection<Range<Token>> ranges, String reason) intvoidsetConcurrentMerkleTreeRequests(int value) voidsetIncrementalRepairDiskHeadroomRejectRatio(double value) voidsetPaxosRepairParallelism(int v) voidsetRepairPendingCompactionRejectThreshold(int value) voidsetRepairSessionSpaceInMebibytes(int sizeInMebibytes) Deprecated.See CASSANDRA-17668voidsetRepairSessionSpaceInMegabytes(int sizeInMegabytes) Deprecated.See CASSANDRA-15234voidsetRepairSessionSpaceInMiB(int sizeInMebibytes) voidsetUseOffheapMerkleTrees(boolean value) voidshutdownNowAndWait(long timeout, TimeUnit unit) voidstart()voidstop()submitRepairSession(TimeUUID parentRepairSession, CommonRange range, String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, boolean repairPaxos, boolean paxosOnly, ExecutorPlus executor, Scheduler validationScheduler, String... cfnames) Requests repairs for the given keyspace and column families.voidvalidation(UUID id) booleanverifyCompactionsPendingThreshold(TimeUUID parentRepairSession, PreviewKind previewKind) booleanverifyDiskHeadroomThreshold(TimeUUID parentRepairSession, PreviewKind previewKind)
-
Field Details
-
consistent
-
UNREPAIRED_SSTABLE
public static final long UNREPAIRED_SSTABLE- See Also:
-
NO_PENDING_REPAIR
-
ctx
-
snapshotExecutor
-
-
Constructor Details
-
ActiveRepairService
public ActiveRepairService()
-
-
Method Details
-
instance
-
repairCommandExecutor
-
start
public void start() -
clearLocalRepairState
public void clearLocalRepairState() -
stop
public void stop() -
getSessions
- Specified by:
getSessionsin interfaceActiveRepairServiceMBean
-
failSession
- Specified by:
failSessionin interfaceActiveRepairServiceMBean
-
setRepairSessionSpaceInMegabytes
Deprecated.See CASSANDRA-15234- Specified by:
setRepairSessionSpaceInMegabytesin interfaceActiveRepairServiceMBean
-
getRepairSessionSpaceInMegabytes
Deprecated.See CASSANDRA-15234- Specified by:
getRepairSessionSpaceInMegabytesin interfaceActiveRepairServiceMBean
-
setRepairSessionSpaceInMebibytes
Deprecated.See CASSANDRA-17668- Specified by:
setRepairSessionSpaceInMebibytesin interfaceActiveRepairServiceMBean
-
getRepairSessionSpaceInMebibytes
Deprecated.See CASSANDRA-17668- Specified by:
getRepairSessionSpaceInMebibytesin interfaceActiveRepairServiceMBean
-
setRepairSessionSpaceInMiB
public void setRepairSessionSpaceInMiB(int sizeInMebibytes) - Specified by:
setRepairSessionSpaceInMiBin interfaceActiveRepairServiceMBean
-
getRepairSessionSpaceInMiB
public int getRepairSessionSpaceInMiB()- Specified by:
getRepairSessionSpaceInMiBin interfaceActiveRepairServiceMBean
-
getConcurrentMerkleTreeRequests
public int getConcurrentMerkleTreeRequests()- Specified by:
getConcurrentMerkleTreeRequestsin interfaceActiveRepairServiceMBean
-
setConcurrentMerkleTreeRequests
public void setConcurrentMerkleTreeRequests(int value) - Specified by:
setConcurrentMerkleTreeRequestsin interfaceActiveRepairServiceMBean
-
getRepairStats
- Specified by:
getRepairStatsin interfaceActiveRepairServiceMBean
-
getPendingStats
- Specified by:
getPendingStatsin interfaceActiveRepairServiceMBean
-
cleanupPending
public List<CompositeData> cleanupPending(List<String> schemaArgs, String rangeString, boolean force) - Specified by:
cleanupPendingin interfaceActiveRepairServiceMBean
-
parentRepairSessionsCount
public int parentRepairSessionsCount()Description copied from interface:ActiveRepairServiceMBeanEach ongoing repair (incremental and non-incremental) is represented by aActiveRepairService.ParentRepairSessionentry in theActiveRepairServicecache. Returns the current number of ongoing repairs (the current number of cached entries).- Specified by:
parentRepairSessionsCountin interfaceActiveRepairServiceMBean- Returns:
- current size of the internal cache holding
ActiveRepairService.ParentRepairSessioninstances
-
submitRepairSession
public RepairSession submitRepairSession(TimeUUID parentRepairSession, CommonRange range, String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, boolean repairPaxos, boolean paxosOnly, ExecutorPlus executor, Scheduler validationScheduler, 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
-
getUseOffheapMerkleTrees
public boolean getUseOffheapMerkleTrees()- Specified by:
getUseOffheapMerkleTreesin interfaceActiveRepairServiceMBean
-
setUseOffheapMerkleTrees
public void setUseOffheapMerkleTrees(boolean value) - Specified by:
setUseOffheapMerkleTreesin interfaceActiveRepairServiceMBean
-
terminateSessions
public void terminateSessions() -
recordRepairStatus
public void recordRepairStatus(int cmd, ActiveRepairService.ParentRepairStatus parentRepairStatus, List<String> messages) -
getRepairStatus
-
getNeighbors
public EndpointsForRange getNeighbors(String keyspaceName, Iterable<Range<Token>> keyspaceLocalRanges, Range<Token> toRepair, Collection<String> dataCenters, Collection<String> hosts) Return all of the neighbors with whom we share the provided range.- Parameters:
keyspaceName- keyspace to repairkeyspaceLocalRanges- local-range for given keyspaceNametoRepair- token to repairdataCenters- the data centers to involve in the repair- Returns:
- neighbors with whom we share the provided range
-
verifyCompactionsPendingThreshold
public boolean verifyCompactionsPendingThreshold(TimeUUID parentRepairSession, PreviewKind previewKind) -
verifyDiskHeadroomThreshold
-
prepareForRepair
public Future<?> prepareForRepair(TimeUUID parentRepairSession, InetAddressAndPort coordinator, Set<InetAddressAndPort> endpoints, RepairOption options, boolean isForcedRepair, List<ColumnFamilyStore> columnFamilyStores) -
cleanUp
Send Verb.CLEANUP_MSG to the given endpoints. This results in removing parent session object from the endpoint's cache. This method does not throw an exception in case of a messaging failure. -
registerParentRepairSession
public void registerParentRepairSession(TimeUUID parentRepairSession, InetAddressAndPort coordinator, List<ColumnFamilyStore> columnFamilyStores, Collection<Range<Token>> ranges, boolean isIncremental, long repairedAt, boolean isGlobal, PreviewKind previewKind) -
getParentRepairSession
public ActiveRepairService.ParentRepairSession getParentRepairSession(TimeUUID parentSessionId) throws NoSuchRepairSessionException We assume when calling this method that a parent session for the provided identifier exists, and that session is still in progress. When it doesn't, that should mean eitherabort(Predicate, String)orfailRepair(TimeUUID, String)have removed it.- Parameters:
parentSessionId- an identifier for an active parent repair session- Returns:
- the
ActiveRepairService.ParentRepairSessionassociated with the provided identifier - Throws:
NoSuchRepairSessionException- if the provided identifier does not map to an active parent session
-
removeParentRepairSession
called when the repair session is done - either failed or anticompaction has completedclears out any snapshots created by this repair
- Parameters:
parentSessionId- an identifier for an active parent repair session- Returns:
- the
ActiveRepairService.ParentRepairSessionassociated with the provided identifier - See Also:
-
handleMessage
-
onJoin
Description copied from interface:IEndpointStateChangeSubscriberUse to inform interested parties about the change in the state for specified endpoint- Specified by:
onJoinin interfaceIEndpointStateChangeSubscriber- Parameters:
endpoint- endpoint for which the state change occurred.epState- state that actually changed for the above endpoint.
-
beforeChange
public void beforeChange(InetAddressAndPort endpoint, EndpointState currentState, ApplicationState newStateKey, VersionedValue newValue) - Specified by:
beforeChangein interfaceIEndpointStateChangeSubscriber
-
onChange
- Specified by:
onChangein interfaceIEndpointStateChangeSubscriber
-
onAlive
- Specified by:
onAlivein interfaceIEndpointStateChangeSubscriber
-
onDead
- Specified by:
onDeadin interfaceIEndpointStateChangeSubscriber
-
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
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:
convictin interfaceIFailureDetectionEventListener- Parameters:
ep- endpoint to be convictedphi- the value of phi with with ep was convicted
-
getRepairPendingCompactionRejectThreshold
public int getRepairPendingCompactionRejectThreshold()- Specified by:
getRepairPendingCompactionRejectThresholdin interfaceActiveRepairServiceMBean
-
setRepairPendingCompactionRejectThreshold
public void setRepairPendingCompactionRejectThreshold(int value) - Specified by:
setRepairPendingCompactionRejectThresholdin interfaceActiveRepairServiceMBean
-
getIncrementalRepairDiskHeadroomRejectRatio
public double getIncrementalRepairDiskHeadroomRejectRatio()- Specified by:
getIncrementalRepairDiskHeadroomRejectRatioin interfaceActiveRepairServiceMBean
-
setIncrementalRepairDiskHeadroomRejectRatio
public void setIncrementalRepairDiskHeadroomRejectRatio(double value) - Specified by:
setIncrementalRepairDiskHeadroomRejectRatioin interfaceActiveRepairServiceMBean
-
abort
Remove any parent repair sessions matching predicate -
parentRepairSessionCount
public int parentRepairSessionCount() -
sessionCount
public int sessionCount() -
repairPaxosForTopologyChange
-
getPaxosRepairParallelism
public int getPaxosRepairParallelism()- Specified by:
getPaxosRepairParallelismin interfaceActiveRepairServiceMBean
-
setPaxosRepairParallelism
public void setPaxosRepairParallelism(int v) - Specified by:
setPaxosRepairParallelismin interfaceActiveRepairServiceMBean
-
shutdownNowAndWait
public void shutdownNowAndWait(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-
coordinators
-
coordinator
-
register
-
register
-
participates
-
participate
-
validations
-
validation
-