use of org.apache.cassandra.repair.messages.FinalizePromise in project cassandra by apache.
the class CoordinatorSessionsTest method handlePromiseResponseNoSession.
@Test
public void handlePromiseResponseNoSession() {
InstrumentedCoordinatorSessions sessions = new InstrumentedCoordinatorSessions();
UUID fakeID = UUIDGen.getTimeUUID();
sessions.handleFinalizePromiseMessage(new FinalizePromise(fakeID, PARTICIPANT1, true));
Assert.assertNull(sessions.getSession(fakeID));
}
use of org.apache.cassandra.repair.messages.FinalizePromise in project cassandra by apache.
the class CoordinatorSessionsTest method handlePromiseResponse.
@Test
public void handlePromiseResponse() {
InstrumentedCoordinatorSessions sessions = new InstrumentedCoordinatorSessions();
UUID sessionID = registerSession();
InstrumentedCoordinatorSession session = sessions.registerSession(sessionID, PARTICIPANTS);
Assert.assertEquals(0, session.finalizePromiseCalls);
sessions.handleFinalizePromiseMessage(new FinalizePromise(sessionID, PARTICIPANT1, true));
Assert.assertEquals(1, session.finalizePromiseCalls);
Assert.assertEquals(PARTICIPANT1, session.promisePeer);
Assert.assertEquals(true, session.promiseSuccess);
}
use of org.apache.cassandra.repair.messages.FinalizePromise in project cassandra by apache.
the class LocalSessionTest method finalizeProposeSuccessCase.
/**
* In the success case, session state should be set to FINALIZE_PROMISED and
* persisted, and a FinalizePromise message should be sent back to the coordinator
*/
@Test
public void finalizeProposeSuccessCase() {
UUID sessionID = registerSession();
InstrumentedLocalSessions sessions = new InstrumentedLocalSessions();
sessions.start();
// create session and move to preparing
LocalSession session = sessions.prepareForTest(sessionID);
sessions.maybeSetRepairing(sessionID);
//
Assert.assertEquals(REPAIRING, session.getState());
// should send a promised message to coordinator and set session state accordingly
sessions.sentMessages.clear();
sessions.handleFinalizeProposeMessage(COORDINATOR, new FinalizePropose(sessionID));
Assert.assertEquals(FINALIZE_PROMISED, session.getState());
Assert.assertEquals(session, sessions.loadUnsafe(sessionID));
assertMessagesSent(sessions, COORDINATOR, new FinalizePromise(sessionID, PARTICIPANT1, true));
}
use of org.apache.cassandra.repair.messages.FinalizePromise in project cassandra by apache.
the class LocalSessions method handleFinalizeProposeMessage.
public void handleFinalizeProposeMessage(InetAddress from, FinalizePropose propose) {
logger.debug("received {} from {}", propose, from);
UUID sessionID = propose.sessionID;
LocalSession session = getSession(sessionID);
if (session == null) {
logger.debug("No LocalSession found for session {}, responding with failure", sessionID);
sendMessage(from, new FailSession(sessionID));
return;
}
try {
setStateAndSave(session, FINALIZE_PROMISED);
sendMessage(from, new FinalizePromise(sessionID, getBroadcastAddress(), true));
} catch (IllegalArgumentException e) {
logger.error("error setting session to FINALIZE_PROMISED", e);
failSession(sessionID);
}
}
Aggregations