use of org.apache.cassandra.repair.messages.FailSession in project cassandra by apache.
the class CoordinatorSession method fail.
public synchronized void fail(Executor executor) {
logger.debug("Failing session {}", sessionID);
FailSession message = new FailSession(sessionID);
for (final InetAddress participant : participants) {
if (participantStates.get(participant) != State.FAILED) {
executor.execute(() -> sendMessage(participant, message));
}
}
setAll(State.FAILED);
}
use of org.apache.cassandra.repair.messages.FailSession in project cassandra by apache.
the class LocalSessions method handlePrepareMessage.
/**
* The PrepareConsistentRequest effectively promotes the parent repair session to a consistent
* incremental session, and begins the 'pending anti compaction' which moves all sstable data
* that is to be repaired into it's own silo, preventing it from mixing with other data.
*
* No response is sent to the repair coordinator until the pending anti compaction has completed
* successfully. If the pending anti compaction fails, a failure message is sent to the coordinator,
* cancelling the session.
*/
public void handlePrepareMessage(InetAddress from, PrepareConsistentRequest request) {
logger.debug("received {} from {}", request, from);
UUID sessionID = request.parentSession;
InetAddress coordinator = request.coordinator;
Set<InetAddress> peers = request.participants;
ActiveRepairService.ParentRepairSession parentSession;
try {
parentSession = getParentRepairSession(sessionID);
} catch (Throwable e) {
logger.debug("Error retrieving ParentRepairSession for session {}, responding with failure", sessionID);
sendMessage(coordinator, new FailSession(sessionID));
return;
}
LocalSession session = createSessionUnsafe(sessionID, parentSession, peers);
putSessionUnsafe(session);
logger.debug("created local session for {}", sessionID);
ExecutorService executor = Executors.newFixedThreadPool(parentSession.getColumnFamilyStores().size());
ListenableFuture pendingAntiCompaction = submitPendingAntiCompaction(session, executor);
Futures.addCallback(pendingAntiCompaction, new FutureCallback() {
public void onSuccess(@Nullable Object result) {
logger.debug("pending anti-compaction for {} completed", sessionID);
setStateAndSave(session, PREPARED);
sendMessage(coordinator, new PrepareConsistentResponse(sessionID, getBroadcastAddress(), true));
executor.shutdown();
}
public void onFailure(Throwable t) {
logger.debug("pending anti-compaction for {} failed", sessionID);
failSession(sessionID);
executor.shutdown();
}
});
}
use of org.apache.cassandra.repair.messages.FailSession in project cassandra by apache.
the class LocalSessions method cancelSession.
/**
* 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
*/
public void cancelSession(UUID sessionID, boolean force) {
logger.debug("cancelling session {}", sessionID);
LocalSession session = getSession(sessionID);
Preconditions.checkArgument(session != null, "Session {} does not exist", sessionID);
Preconditions.checkArgument(force || session.coordinator.equals(getBroadcastAddress()), "Cancel session %s from it's coordinator (%s) or use --force", sessionID, session.coordinator);
setStateAndSave(session, FAILED);
for (InetAddress participant : session.participants) {
if (!participant.equals(getBroadcastAddress()))
sendMessage(participant, new FailSession(sessionID));
}
}
use of org.apache.cassandra.repair.messages.FailSession in project cassandra by apache.
the class LocalSessions method failSession.
public void failSession(UUID sessionID, boolean sendMessage) {
logger.debug("failing session {}", sessionID);
LocalSession session = getSession(sessionID);
if (session != null) {
setStateAndSave(session, FAILED);
if (sendMessage) {
sendMessage(session.coordinator, new FailSession(sessionID));
}
}
}
use of org.apache.cassandra.repair.messages.FailSession in project cassandra by apache.
the class LocalSessionTest method handleFailMessage.
/**
* Session should be failed, but no messages should be sent
*/
@Test
public void handleFailMessage() {
UUID sessionID = registerSession();
InstrumentedLocalSessions sessions = new InstrumentedLocalSessions();
sessions.start();
LocalSession session = sessions.prepareForTest(sessionID);
Assert.assertEquals(PREPARED, session.getState());
sessions.sentMessages.clear();
sessions.handleFailSessionMessage(PARTICIPANT1, new FailSession(sessionID));
Assert.assertEquals(FAILED, session.getState());
Assert.assertTrue(sessions.sentMessages.isEmpty());
}
Aggregations