Search in sources :

Example 6 with FinalizePropose

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));
}
Also used : FinalizeCommit(org.apache.cassandra.repair.messages.FinalizeCommit) UUID(java.util.UUID) FinalizePropose(org.apache.cassandra.repair.messages.FinalizePropose) AbstractRepairTest(org.apache.cassandra.repair.AbstractRepairTest) Test(org.junit.Test)

Example 7 with FinalizePropose

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));
}
Also used : UUID(java.util.UUID) FinalizePropose(org.apache.cassandra.repair.messages.FinalizePropose) FailSession(org.apache.cassandra.repair.messages.FailSession) AbstractRepairTest(org.apache.cassandra.repair.AbstractRepairTest) Test(org.junit.Test)

Example 8 with FinalizePropose

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));
}
Also used : FinalizePromise(org.apache.cassandra.repair.messages.FinalizePromise) UUID(java.util.UUID) FinalizePropose(org.apache.cassandra.repair.messages.FinalizePropose) AbstractRepairTest(org.apache.cassandra.repair.AbstractRepairTest) Test(org.junit.Test)

Aggregations

FinalizePropose (org.apache.cassandra.repair.messages.FinalizePropose)8 AbstractRepairTest (org.apache.cassandra.repair.AbstractRepairTest)7 Test (org.junit.Test)7 UUID (java.util.UUID)5 InetAddress (java.net.InetAddress)3 FailSession (org.apache.cassandra.repair.messages.FailSession)3 FinalizeCommit (org.apache.cassandra.repair.messages.FinalizeCommit)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Executor (java.util.concurrent.Executor)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 RepairSessionResult (org.apache.cassandra.repair.RepairSessionResult)2 PrepareConsistentRequest (org.apache.cassandra.repair.messages.PrepareConsistentRequest)2 RepairMessage (org.apache.cassandra.repair.messages.RepairMessage)2 FinalizePromise (org.apache.cassandra.repair.messages.FinalizePromise)1 Assert (org.junit.Assert)1