Search in sources :

Example 16 with FailSession

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

Example 17 with FailSession

use of org.apache.cassandra.repair.messages.FailSession 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

FailSession (org.apache.cassandra.repair.messages.FailSession)17 AbstractRepairTest (org.apache.cassandra.repair.AbstractRepairTest)12 Test (org.junit.Test)12 UUID (java.util.UUID)10 InetAddress (java.net.InetAddress)7 PrepareConsistentRequest (org.apache.cassandra.repair.messages.PrepareConsistentRequest)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Executor (java.util.concurrent.Executor)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 RepairSessionResult (org.apache.cassandra.repair.RepairSessionResult)3 FinalizePropose (org.apache.cassandra.repair.messages.FinalizePropose)3 RepairMessage (org.apache.cassandra.repair.messages.RepairMessage)3 Assert (org.junit.Assert)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 ExecutorService (java.util.concurrent.ExecutorService)1 FinalizePromise (org.apache.cassandra.repair.messages.FinalizePromise)1 PrepareConsistentResponse (org.apache.cassandra.repair.messages.PrepareConsistentResponse)1 ActiveRepairService (org.apache.cassandra.service.ActiveRepairService)1