use of org.apache.cassandra.repair.messages.FinalizePropose in project cassandra by apache.
the class LocalSessionTest method finalRepairedAtFinalized.
@Test
public void finalRepairedAtFinalized() {
UUID sessionID = registerSession();
InstrumentedLocalSessions sessions = new InstrumentedLocalSessions();
sessions.start();
sessions.prepareForTest(sessionID);
sessions.maybeSetRepairing(sessionID);
sessions.handleFinalizeProposeMessage(COORDINATOR, new FinalizePropose(sessionID));
sessions.handleFinalizeCommitMessage(PARTICIPANT1, new FinalizeCommit(sessionID));
LocalSession session = sessions.getSession(sessionID);
Assert.assertTrue(session.repairedAt != ActiveRepairService.UNREPAIRED_SSTABLE);
Assert.assertEquals(session.repairedAt, sessions.getFinalSessionRepairedAt(sessionID));
}
use of org.apache.cassandra.repair.messages.FinalizePropose in project cassandra by apache.
the class LocalSessionTest method finalizeProposeInvalidStateFailure.
/**
* Trying to propose finalization when the session isn't in the repaired
* state should fail the session and send a failure message to the proposer
*/
@Test
public void finalizeProposeInvalidStateFailure() {
UUID sessionID = registerSession();
InstrumentedLocalSessions sessions = new InstrumentedLocalSessions();
sessions.start();
LocalSession session = sessions.prepareForTest(sessionID);
Assert.assertEquals(PREPARED, session.getState());
// should fail the session and send a failure message to the coordinator
sessions.sentMessages.clear();
sessions.handleFinalizeProposeMessage(COORDINATOR, new FinalizePropose(sessionID));
Assert.assertEquals(FAILED, session.getState());
Assert.assertEquals(session, sessions.loadUnsafe(sessionID));
assertMessagesSent(sessions, COORDINATOR, new FailSession(sessionID));
}
use of org.apache.cassandra.repair.messages.FinalizePropose 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));
}
Aggregations