Search in sources :

Example 1 with RepairSession

use of org.apache.cassandra.repair.RepairSession in project cassandra by apache.

the class ActiveRepairService method submitRepairSession.

/**
     * Requests repairs for the given keyspace and column families.
     *
     * @return Future for asynchronous call or null if there is no need to repair
     */
public RepairSession submitRepairSession(UUID parentRepairSession, Collection<Range<Token>> range, String keyspace, RepairParallelism parallelismDegree, Set<InetAddress> endpoints, long repairedAt, boolean isConsistent, boolean pullRepair, ListeningExecutorService executor, String... cfnames) {
    if (endpoints.isEmpty())
        return null;
    if (cfnames.length == 0)
        return null;
    final RepairSession session = new RepairSession(parentRepairSession, UUIDGen.getTimeUUID(), range, keyspace, parallelismDegree, endpoints, repairedAt, isConsistent, pullRepair, cfnames);
    sessions.put(session.getId(), session);
    // register listeners
    registerOnFdAndGossip(session);
    // remove session at completion
    session.addListener(new Runnable() {

        /**
             * When repair finished, do clean up
             */
        public void run() {
            sessions.remove(session.getId());
        }
    }, MoreExecutors.directExecutor());
    session.start(executor);
    return session;
}
Also used : RepairSession(org.apache.cassandra.repair.RepairSession)

Example 2 with RepairSession

use of org.apache.cassandra.repair.RepairSession in project cassandra by apache.

the class ActiveRepairService method handleMessage.

public void handleMessage(InetAddress endpoint, RepairMessage message) {
    RepairJobDesc desc = message.desc;
    RepairSession session = sessions.get(desc.sessionId);
    if (session == null)
        return;
    switch(message.messageType) {
        case VALIDATION_COMPLETE:
            ValidationComplete validation = (ValidationComplete) message;
            session.validationComplete(desc, endpoint, validation.trees);
            break;
        case SYNC_COMPLETE:
            // one of replica is synced.
            SyncComplete sync = (SyncComplete) message;
            session.syncComplete(desc, sync.nodes, sync.success);
            break;
        default:
            break;
    }
}
Also used : RepairJobDesc(org.apache.cassandra.repair.RepairJobDesc) RepairSession(org.apache.cassandra.repair.RepairSession)

Example 3 with RepairSession

use of org.apache.cassandra.repair.RepairSession in project cassandra by apache.

the class ActiveRepairService method terminateSessions.

public synchronized void terminateSessions() {
    Throwable cause = new IOException("Terminate session is called");
    for (RepairSession session : sessions.values()) {
        session.forceShutdown(cause);
    }
    parentRepairSessions.clear();
}
Also used : RepairSession(org.apache.cassandra.repair.RepairSession) IOException(java.io.IOException)

Aggregations

RepairSession (org.apache.cassandra.repair.RepairSession)3 IOException (java.io.IOException)1 RepairJobDesc (org.apache.cassandra.repair.RepairJobDesc)1