Search in sources :

Example 1 with FinalizePromise

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

Example 2 with FinalizePromise

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

Example 3 with FinalizePromise

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));
}
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)

Example 4 with FinalizePromise

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

Aggregations

UUID (java.util.UUID)4 FinalizePromise (org.apache.cassandra.repair.messages.FinalizePromise)4 AbstractRepairTest (org.apache.cassandra.repair.AbstractRepairTest)3 Test (org.junit.Test)3 FailSession (org.apache.cassandra.repair.messages.FailSession)1 FinalizePropose (org.apache.cassandra.repair.messages.FinalizePropose)1