use of org.apache.cassandra.repair.messages.PrepareConsistentRequest in project cassandra by apache.
the class LocalSessionTest method prepareSuccessCase.
@Test
public void prepareSuccessCase() {
UUID sessionID = registerSession();
InstrumentedLocalSessions sessions = new InstrumentedLocalSessions();
sessions.start();
// replacing future so we can inspect state before and after anti compaction callback
sessions.prepareSessionFuture = new AsyncPromise<>();
Assert.assertFalse(sessions.prepareSessionCalled);
sessions.handlePrepareMessage(PARTICIPANT1, new PrepareConsistentRequest(sessionID, COORDINATOR, PARTICIPANTS));
Assert.assertTrue(sessions.prepareSessionCalled);
Assert.assertTrue(sessions.sentMessages.isEmpty());
// anti compaction hasn't finished yet, so state in memory and on disk should be PREPARING
LocalSession session = sessions.getSession(sessionID);
Assert.assertNotNull(session);
Assert.assertEquals(PREPARING, session.getState());
Assert.assertEquals(session, sessions.loadUnsafe(sessionID));
// anti compaction has now finished, so state in memory and on disk should be PREPARED
sessions.prepareSessionFuture.trySuccess(null);
session = sessions.getSession(sessionID);
Assert.assertNotNull(session);
Assert.assertEquals(PREPARED, session.getState());
Assert.assertEquals(session, sessions.loadUnsafe(sessionID));
// ...and we should have sent a success message back to the coordinator
assertMessagesSent(sessions, COORDINATOR, new PrepareConsistentResponse(sessionID, PARTICIPANT1, true));
}
use of org.apache.cassandra.repair.messages.PrepareConsistentRequest in project cassandra by apache.
the class LocalSessionTest method prepareWithNonExistantParentSession.
/**
* If a ParentRepairSession wasn't previously created, we shouldn't
* create a session locally, but we should send a failure message to
* the coordinator.
*/
@Test
public void prepareWithNonExistantParentSession() {
UUID sessionID = UUIDGen.getTimeUUID();
InstrumentedLocalSessions sessions = new InstrumentedLocalSessions();
sessions.handlePrepareMessage(PARTICIPANT1, new PrepareConsistentRequest(sessionID, COORDINATOR, PARTICIPANTS));
Assert.assertNull(sessions.getSession(sessionID));
assertMessagesSent(sessions, COORDINATOR, new PrepareConsistentResponse(sessionID, PARTICIPANT1, false));
}
use of org.apache.cassandra.repair.messages.PrepareConsistentRequest in project cassandra by apache.
the class LocalSessionTest method isSessionInProgress.
/**
* Check all states (except failed)
*/
@Test
public void isSessionInProgress() {
UUID sessionID = registerSession();
InstrumentedLocalSessions sessions = new InstrumentedLocalSessions();
sessions.start();
// prevent moving to prepared
sessions.prepareSessionFuture = new AsyncPromise<>();
sessions.handlePrepareMessage(PARTICIPANT1, new PrepareConsistentRequest(sessionID, COORDINATOR, PARTICIPANTS));
LocalSession session = sessions.getSession(sessionID);
Assert.assertNotNull(session);
Assert.assertEquals(PREPARING, session.getState());
Assert.assertTrue(sessions.isSessionInProgress(sessionID));
session.setState(PREPARED);
Assert.assertTrue(sessions.isSessionInProgress(sessionID));
session.setState(REPAIRING);
Assert.assertTrue(sessions.isSessionInProgress(sessionID));
session.setState(FINALIZE_PROMISED);
Assert.assertTrue(sessions.isSessionInProgress(sessionID));
session.setState(FINALIZED);
Assert.assertFalse(sessions.isSessionInProgress(sessionID));
}
Aggregations