Search in sources :

Example 1 with SyncResponse

use of org.apache.cassandra.repair.messages.SyncResponse in project cassandra by apache.

the class ActiveRepairService method handleMessage.

public void handleMessage(Message<? extends RepairMessage> message) {
    RepairMessage payload = message.payload;
    RepairJobDesc desc = payload.desc;
    RepairSession session = sessions.get(desc.sessionId);
    if (session == null) {
        if (payload instanceof ValidationResponse) {
            // The trees may be off-heap, and will therefore need to be released.
            ValidationResponse validation = (ValidationResponse) payload;
            MerkleTrees trees = validation.trees;
            // The response from a failed validation won't have any trees.
            if (trees != null)
                trees.release();
        }
        return;
    }
    switch(message.verb()) {
        case VALIDATION_RSP:
            ValidationResponse validation = (ValidationResponse) payload;
            session.validationComplete(desc, message.from(), validation.trees);
            break;
        case SYNC_RSP:
            // one of replica is synced.
            SyncResponse sync = (SyncResponse) payload;
            session.syncComplete(desc, sync.nodes, sync.success, sync.summaries);
            break;
        default:
            break;
    }
}
Also used : RepairMessage(org.apache.cassandra.repair.messages.RepairMessage) MerkleTrees(org.apache.cassandra.utils.MerkleTrees) SyncResponse(org.apache.cassandra.repair.messages.SyncResponse) RepairJobDesc(org.apache.cassandra.repair.RepairJobDesc) ValidationResponse(org.apache.cassandra.repair.messages.ValidationResponse) RepairSession(org.apache.cassandra.repair.RepairSession)

Aggregations

RepairJobDesc (org.apache.cassandra.repair.RepairJobDesc)1 RepairSession (org.apache.cassandra.repair.RepairSession)1 RepairMessage (org.apache.cassandra.repair.messages.RepairMessage)1 SyncResponse (org.apache.cassandra.repair.messages.SyncResponse)1 ValidationResponse (org.apache.cassandra.repair.messages.ValidationResponse)1 MerkleTrees (org.apache.cassandra.utils.MerkleTrees)1