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 java.lang.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 Classes Modifier and Type Class Description static classActiveRepairService.ConsistentSessionsstatic classActiveRepairService.ParentRepairSessionWe 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 classActiveRepairService.ParentRepairStatusstatic classActiveRepairService.RepairCommandExecutorHandle
-
Field Summary
Fields Modifier and Type Field Description ActiveRepairService.ConsistentSessionsconsistentstatic ActiveRepairServiceinstancestatic TimeUUIDNO_PENDING_REPAIRExecutorPlussnapshotExecutorstatic longUNREPAIRED_SSTABLE-
Fields inherited from interface org.apache.cassandra.service.ActiveRepairServiceMBean
MBEAN_NAME
-
-
Constructor Summary
Constructors Constructor Description ActiveRepairService(IFailureDetector failureDetector, Gossiper gossiper)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidabort(java.util.function.Predicate<ActiveRepairService.ParentRepairSession> predicate, java.lang.String message)Remove any parent repair sessions matching predicatevoidbeforeChange(InetAddressAndPort endpoint, EndpointState currentState, ApplicationState newStateKey, VersionedValue newValue)voidcleanUp(TimeUUID parentRepairSession, java.util.Set<InetAddressAndPort> endpoints)Send Verb.CLEANUP_MSG to the given endpoints.java.util.List<javax.management.openmbean.CompositeData>cleanupPending(java.util.List<java.lang.String> schemaArgs, java.lang.String rangeString, boolean force)voidclearLocalRepairState()voidconvict(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.CoordinatorStatecoordinator(TimeUUID id)java.util.Collection<CoordinatorState>coordinators()voidfailSession(java.lang.String session, boolean force)intgetConcurrentMerkleTreeRequests()static EndpointsForRangegetNeighbors(java.lang.String keyspaceName, java.lang.Iterable<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.ParentRepairSessiongetParentRepairSession(TimeUUID parentSessionId)We assume when calling this method that a parent session for the provided identifier exists, and that session is still in progress.intgetPaxosRepairParallelism()java.util.List<javax.management.openmbean.CompositeData>getPendingStats(java.util.List<java.lang.String> schemaArgs, java.lang.String rangeString)intgetRepairPendingCompactionRejectThreshold()intgetRepairSessionSpaceInMebibytes()intgetRepairSessionSpaceInMegabytes()Deprecated.java.util.List<javax.management.openmbean.CompositeData>getRepairStats(java.util.List<java.lang.String> schemaArgs, java.lang.String rangeString)Pair<ActiveRepairService.ParentRepairStatus,java.util.List<java.lang.String>>getRepairStatus(java.lang.Integer cmd)java.util.List<java.util.Map<java.lang.String,java.lang.String>>getSessions(boolean all, java.lang.String rangesStr)booleangetUseOffheapMerkleTrees()voidhandleMessage(Message<? extends RepairMessage> message)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.intparentRepairSessionCount()intparentRepairSessionsCount()Each ongoing repair (incremental and non-incremental) is represented by aActiveRepairService.ParentRepairSessionentry in theActiveRepairServicecache.ParticipateStateparticipate(TimeUUID id)java.util.Collection<ParticipateState>participates()TimeUUIDprepareForRepair(TimeUUID parentRepairSession, InetAddressAndPort coordinator, java.util.Set<InetAddressAndPort> endpoints, RepairOption options, boolean isForcedRepair, java.util.List<ColumnFamilyStore> columnFamilyStores)voidrecordRepairStatus(int cmd, ActiveRepairService.ParentRepairStatus parentRepairStatus, java.util.List<java.lang.String> messages)voidregister(CoordinatorState state)booleanregister(ParticipateState state)voidregisterParentRepairSession(TimeUUID parentRepairSession, InetAddressAndPort coordinator, java.util.List<ColumnFamilyStore> columnFamilyStores, java.util.Collection<Range<Token>> ranges, boolean isIncremental, long repairedAt, boolean isGlobal, PreviewKind previewKind)ActiveRepairService.ParentRepairSessionremoveParentRepairSession(TimeUUID parentSessionId)called when the repair session is done - either failed or anticompaction has completedstatic ExecutorPlusrepairCommandExecutor()Future<?>repairPaxosForTopologyChange(java.lang.String ksName, java.util.Collection<Range<Token>> ranges, java.lang.String reason)intsessionCount()voidsetConcurrentMerkleTreeRequests(int value)voidsetPaxosRepairParallelism(int v)voidsetRepairPendingCompactionRejectThreshold(int value)voidsetRepairSessionSpaceInMebibytes(int sizeInMebibytes)voidsetRepairSessionSpaceInMegabytes(int sizeInMegabytes)Deprecated.voidsetUseOffheapMerkleTrees(boolean value)voidshutdownNowAndWait(long timeout, java.util.concurrent.TimeUnit unit)voidstart()voidstop()RepairSessionsubmitRepairSession(TimeUUID parentRepairSession, CommonRange range, java.lang.String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, boolean repairPaxos, boolean paxosOnly, ExecutorPlus executor, Scheduler validationScheduler, java.lang.String... cfnames)Requests repairs for the given keyspace and column families.voidterminateSessions()ValidationStatevalidation(java.util.UUID id)java.util.Collection<ValidationState>validations()static booleanverifyCompactionsPendingThreshold(TimeUUID parentRepairSession, PreviewKind previewKind)
-
-
-
Field Detail
-
consistent
public final ActiveRepairService.ConsistentSessions consistent
-
instance
public static final ActiveRepairService instance
-
UNREPAIRED_SSTABLE
public static final long UNREPAIRED_SSTABLE
- See Also:
- Constant Field Values
-
NO_PENDING_REPAIR
public static final TimeUUID NO_PENDING_REPAIR
-
snapshotExecutor
public final ExecutorPlus snapshotExecutor
-
-
Constructor Detail
-
ActiveRepairService
public ActiveRepairService(IFailureDetector failureDetector, Gossiper gossiper)
-
-
Method Detail
-
repairCommandExecutor
public static ExecutorPlus repairCommandExecutor()
-
start
public void start()
-
clearLocalRepairState
public void clearLocalRepairState()
-
stop
public void stop()
-
getSessions
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getSessions(boolean all, java.lang.String rangesStr)- Specified by:
getSessionsin interfaceActiveRepairServiceMBean
-
failSession
public void failSession(java.lang.String session, boolean force)- Specified by:
failSessionin interfaceActiveRepairServiceMBean
-
setRepairSessionSpaceInMegabytes
@Deprecated public void setRepairSessionSpaceInMegabytes(int sizeInMegabytes)
Deprecated.- Specified by:
setRepairSessionSpaceInMegabytesin interfaceActiveRepairServiceMBean
-
getRepairSessionSpaceInMegabytes
@Deprecated public int getRepairSessionSpaceInMegabytes()
Deprecated.- Specified by:
getRepairSessionSpaceInMegabytesin interfaceActiveRepairServiceMBean
-
setRepairSessionSpaceInMebibytes
public void setRepairSessionSpaceInMebibytes(int sizeInMebibytes)
- Specified by:
setRepairSessionSpaceInMebibytesin interfaceActiveRepairServiceMBean
-
getRepairSessionSpaceInMebibytes
public int getRepairSessionSpaceInMebibytes()
- Specified by:
getRepairSessionSpaceInMebibytesin interfaceActiveRepairServiceMBean
-
getConcurrentMerkleTreeRequests
public int getConcurrentMerkleTreeRequests()
- Specified by:
getConcurrentMerkleTreeRequestsin interfaceActiveRepairServiceMBean
-
setConcurrentMerkleTreeRequests
public void setConcurrentMerkleTreeRequests(int value)
- Specified by:
setConcurrentMerkleTreeRequestsin interfaceActiveRepairServiceMBean
-
getRepairStats
public java.util.List<javax.management.openmbean.CompositeData> getRepairStats(java.util.List<java.lang.String> schemaArgs, java.lang.String rangeString)- Specified by:
getRepairStatsin interfaceActiveRepairServiceMBean
-
getPendingStats
public java.util.List<javax.management.openmbean.CompositeData> getPendingStats(java.util.List<java.lang.String> schemaArgs, java.lang.String rangeString)- Specified by:
getPendingStatsin interfaceActiveRepairServiceMBean
-
cleanupPending
public java.util.List<javax.management.openmbean.CompositeData> cleanupPending(java.util.List<java.lang.String> schemaArgs, java.lang.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, java.lang.String keyspace, RepairParallelism parallelismDegree, boolean isIncremental, boolean pullRepair, PreviewKind previewKind, boolean optimiseStreams, boolean repairPaxos, boolean paxosOnly, ExecutorPlus executor, Scheduler validationScheduler, 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
-
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, java.util.List<java.lang.String> messages)
-
getRepairStatus
public Pair<ActiveRepairService.ParentRepairStatus,java.util.List<java.lang.String>> getRepairStatus(java.lang.Integer cmd)
-
getNeighbors
public static EndpointsForRange getNeighbors(java.lang.String keyspaceName, java.lang.Iterable<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 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 static boolean verifyCompactionsPendingThreshold(TimeUUID parentRepairSession, PreviewKind previewKind)
-
prepareForRepair
public TimeUUID prepareForRepair(TimeUUID parentRepairSession, InetAddressAndPort coordinator, java.util.Set<InetAddressAndPort> endpoints, RepairOption options, boolean isForcedRepair, java.util.List<ColumnFamilyStore> columnFamilyStores)
-
cleanUp
public void cleanUp(TimeUUID parentRepairSession, java.util.Set<InetAddressAndPort> endpoints)
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, java.util.List<ColumnFamilyStore> columnFamilyStores, java.util.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
public ActiveRepairService.ParentRepairSession removeParentRepairSession(TimeUUID parentSessionId)
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:
CassandraTableRepairManager.snapshot(String, Collection, boolean)
-
handleMessage
public void handleMessage(Message<? extends RepairMessage> message)
-
onJoin
public void onJoin(InetAddressAndPort endpoint, EndpointState epState)
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
public void onChange(InetAddressAndPort endpoint, ApplicationState state, VersionedValue value)
- Specified by:
onChangein interfaceIEndpointStateChangeSubscriber
-
onAlive
public void onAlive(InetAddressAndPort endpoint, EndpointState state)
- Specified by:
onAlivein interfaceIEndpointStateChangeSubscriber
-
onDead
public void onDead(InetAddressAndPort endpoint, EndpointState state)
- Specified by:
onDeadin interfaceIEndpointStateChangeSubscriber
-
onRemove
public void onRemove(InetAddressAndPort endpoint)
- Specified by:
onRemovein interfaceIEndpointStateChangeSubscriber
-
onRestart
public void onRestart(InetAddressAndPort endpoint, EndpointState state)
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 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:
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
-
abort
public void abort(java.util.function.Predicate<ActiveRepairService.ParentRepairSession> predicate, java.lang.String message)
Remove any parent repair sessions matching predicate
-
parentRepairSessionCount
public int parentRepairSessionCount()
-
sessionCount
public int sessionCount()
-
repairPaxosForTopologyChange
public Future<?> repairPaxosForTopologyChange(java.lang.String ksName, java.util.Collection<Range<Token>> ranges, java.lang.String reason)
-
getPaxosRepairParallelism
public int getPaxosRepairParallelism()
- Specified by:
getPaxosRepairParallelismin interfaceActiveRepairServiceMBean
-
setPaxosRepairParallelism
public void setPaxosRepairParallelism(int v)
- Specified by:
setPaxosRepairParallelismin interfaceActiveRepairServiceMBean
-
shutdownNowAndWait
public void shutdownNowAndWait(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.TimeoutException
-
coordinators
public java.util.Collection<CoordinatorState> coordinators()
-
coordinator
public CoordinatorState coordinator(TimeUUID id)
-
register
public void register(CoordinatorState state)
-
register
public boolean register(ParticipateState state)
-
participates
public java.util.Collection<ParticipateState> participates()
-
participate
public ParticipateState participate(TimeUUID id)
-
validations
public java.util.Collection<ValidationState> validations()
-
validation
public ValidationState validation(java.util.UUID id)
-
-