Class LocalSessions
- java.lang.Object
-
- org.apache.cassandra.repair.consistent.LocalSessions
-
public class LocalSessions extends java.lang.Object
Manages all consistent repair sessions a node is participating in. Since sessions need to be loaded, and since we need to handle cases where sessions might not exist, most of the logic around local sessions is implemented in this class, with the LocalSession class being treated more like a simple struct, in contrast withCoordinatorSession
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LocalSessions.Listener
-
Field Summary
Fields Modifier and Type Field Description static int
CLEANUP_INTERVAL
How often LocalSessions.cleanup is run
-
Constructor Summary
Constructors Constructor Description LocalSessions(SharedContext ctx)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LocalSession
buildSession(LocalSession.Builder builder)
void
cancelSession(TimeUUID sessionID, boolean force)
hook for operators to cancel sessions, cancelling from a non-coordinator is an error, unless force is set to true.void
cleanup()
Auto fails and auto deletes timed out and old sessions Compaction will clean up the sstables still owned by a deleted sessionCleanupSummary
cleanup(TableId tid, java.util.Collection<Range<Token>> ranges, boolean force)
void
deleteSession(TimeUUID sessionID)
void
failSession(LocalSession session, boolean sendMessage)
void
failSession(TimeUUID sessionID)
void
failSession(TimeUUID sessionID, boolean sendMessage)
protected InetAddressAndPort
getBroadcastAddressAndPort()
long
getFinalSessionRepairedAt(TimeUUID sessionID)
Returns the repairedAt time for a sessions which is unknown, failed, or finalized calling this for a session which is in progress throws an exceptionprotected ActiveRepairService.ParentRepairSession
getParentRepairSession(TimeUUID sessionID)
PendingStats
getPendingStats(TableId tid, java.util.Collection<Range<Token>> ranges)
RepairedState.Stats
getRepairedStats(TableId tid, java.util.Collection<Range<Token>> ranges)
LocalSession
getSession(TimeUUID sessionID)
void
handleFailSessionMessage(InetAddressAndPort from, FailSession msg)
void
handleFinalizeCommitMessage(Message<? extends RepairMessage> message)
Finalizes the repair session, completing it as successful.void
handleFinalizeProposeMessage(Message<? extends RepairMessage> message)
void
handlePrepareMessage(Message<? extends RepairMessage> message)
The PrepareConsistentRequest promotes the parent repair session to a consistent incremental session, and isolates the data to be repaired from the rest of the table's data No response is sent to the repair coordinator until the data preparation / isolation has completed successfully.void
handleStatusRequest(InetAddressAndPort from, StatusRequest request)
void
handleStatusResponse(InetAddressAndPort from, StatusResponse response)
protected boolean
isAlive(InetAddressAndPort address)
protected boolean
isNodeInitialized()
boolean
isSessionFinalized(TimeUUID sessionID)
determines if a local session exists, and if it's in the finalized stateboolean
isSessionInProgress(TimeUUID sessionID)
determines if a local session exists, and if it's not finalized or failedboolean
isStarted()
void
maybeSetRepairing(TimeUUID sessionID)
static void
registerListener(LocalSessions.Listener listener)
protected void
sendMessage(InetAddressAndPort destination, Message<? extends RepairMessage> message)
void
sendStatusRequest(LocalSession session)
protected void
sessionCompleted(LocalSession session)
boolean
sessionExists(TimeUUID sessionID)
determines if a local session existsprotected boolean
sessionHasData(LocalSession session)
java.util.List<java.util.Map<java.lang.String,java.lang.String>>
sessionInfo(boolean all, java.util.Set<Range<Token>> ranges)
void
start()
Loads sessions out of the repairs table and sets state to startedvoid
stop()
static void
unregisterListener(LocalSessions.Listener listener)
static void
unsafeClearListeners()
-
-
-
Constructor Detail
-
LocalSessions
public LocalSessions(SharedContext ctx)
-
-
Method Detail
-
getBroadcastAddressAndPort
protected InetAddressAndPort getBroadcastAddressAndPort()
-
isAlive
protected boolean isAlive(InetAddressAndPort address)
-
isNodeInitialized
protected boolean isNodeInitialized()
-
sessionInfo
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> sessionInfo(boolean all, java.util.Set<Range<Token>> ranges)
-
getRepairedStats
public RepairedState.Stats getRepairedStats(TableId tid, java.util.Collection<Range<Token>> ranges)
-
getPendingStats
public PendingStats getPendingStats(TableId tid, java.util.Collection<Range<Token>> ranges)
-
cleanup
public CleanupSummary cleanup(TableId tid, java.util.Collection<Range<Token>> ranges, boolean force)
-
cancelSession
public void cancelSession(TimeUUID sessionID, boolean force)
hook for operators to cancel sessions, cancelling from a non-coordinator is an error, unless force is set to true. Messages are sent out to other participants, but we don't wait for a response
-
start
public void start()
Loads sessions out of the repairs table and sets state to started
-
stop
public void stop()
-
isStarted
public boolean isStarted()
-
cleanup
public void cleanup()
Auto fails and auto deletes timed out and old sessions Compaction will clean up the sstables still owned by a deleted session
-
buildSession
protected LocalSession buildSession(LocalSession.Builder builder)
-
getSession
public LocalSession getSession(TimeUUID sessionID)
-
getParentRepairSession
protected ActiveRepairService.ParentRepairSession getParentRepairSession(TimeUUID sessionID) throws NoSuchRepairSessionException
- Throws:
NoSuchRepairSessionException
-
sendMessage
protected void sendMessage(InetAddressAndPort destination, Message<? extends RepairMessage> message)
-
failSession
public void failSession(TimeUUID sessionID)
-
failSession
public void failSession(TimeUUID sessionID, boolean sendMessage)
-
failSession
public void failSession(LocalSession session, boolean sendMessage)
-
deleteSession
public void deleteSession(TimeUUID sessionID)
-
handlePrepareMessage
public void handlePrepareMessage(Message<? extends RepairMessage> message)
The PrepareConsistentRequest promotes the parent repair session to a consistent incremental session, and isolates the data to be repaired from the rest of the table's data No response is sent to the repair coordinator until the data preparation / isolation has completed successfully. If the data preparation fails, a failure message is sent to the coordinator, cancelling the session.
-
maybeSetRepairing
public void maybeSetRepairing(TimeUUID sessionID)
-
handleFinalizeProposeMessage
public void handleFinalizeProposeMessage(Message<? extends RepairMessage> message)
-
sessionCompleted
protected void sessionCompleted(LocalSession session)
-
handleFinalizeCommitMessage
public void handleFinalizeCommitMessage(Message<? extends RepairMessage> message)
Finalizes the repair session, completing it as successful. This only changes the state of the session, it doesn't promote the siloed sstables to repaired. That will happen as part of the compaction process, and avoids having to worry about in progress compactions interfering with the promotion.
-
handleFailSessionMessage
public void handleFailSessionMessage(InetAddressAndPort from, FailSession msg)
-
sendStatusRequest
public void sendStatusRequest(LocalSession session)
-
handleStatusRequest
public void handleStatusRequest(InetAddressAndPort from, StatusRequest request)
-
handleStatusResponse
public void handleStatusResponse(InetAddressAndPort from, StatusResponse response)
-
isSessionInProgress
public boolean isSessionInProgress(TimeUUID sessionID)
determines if a local session exists, and if it's not finalized or failed
-
isSessionFinalized
public boolean isSessionFinalized(TimeUUID sessionID)
determines if a local session exists, and if it's in the finalized state
-
sessionExists
public boolean sessionExists(TimeUUID sessionID)
determines if a local session exists
-
sessionHasData
protected boolean sessionHasData(LocalSession session)
-
getFinalSessionRepairedAt
public long getFinalSessionRepairedAt(TimeUUID sessionID)
Returns the repairedAt time for a sessions which is unknown, failed, or finalized calling this for a session which is in progress throws an exception
-
registerListener
public static void registerListener(LocalSessions.Listener listener)
-
unregisterListener
public static void unregisterListener(LocalSessions.Listener listener)
-
unsafeClearListeners
public static void unsafeClearListeners()
-
-