Search in sources :

Example 1 with CleanupMessage

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

the class ActiveRepairService method cleanUp.

/**
 * Send Verb.CLEANUP_MSG to the given endpoints. This results in removing parent session object from the
 * endpoint's cache.
 * This method does not throw an exception in case of a messaging failure.
 */
public void cleanUp(UUID parentRepairSession, Set<InetAddressAndPort> endpoints) {
    for (InetAddressAndPort endpoint : endpoints) {
        try {
            if (FailureDetector.instance.isAlive(endpoint)) {
                CleanupMessage message = new CleanupMessage(parentRepairSession);
                Message<CleanupMessage> msg = Message.out(Verb.CLEANUP_MSG, message);
                RequestCallback loggingCallback = new RequestCallback() {

                    @Override
                    public void onResponse(Message msg) {
                        logger.trace("Successfully cleaned up {} parent repair session on {}.", parentRepairSession, endpoint);
                    }

                    @Override
                    public void onFailure(InetAddressAndPort from, RequestFailureReason failureReason) {
                        logger.debug("Failed to clean up parent repair session {} on {}. The uncleaned sessions will " + "be removed on a node restart. This should not be a problem unless you see thousands " + "of messages like this.", parentRepairSession, endpoint);
                    }
                };
                MessagingService.instance().sendWithCallback(msg, endpoint, loggingCallback);
            }
        } catch (Exception exc) {
            logger.warn("Failed to send a clean up message to {}", endpoint, exc);
        }
    }
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) RequestFailureReason(org.apache.cassandra.exceptions.RequestFailureReason) RequestCallback(org.apache.cassandra.net.RequestCallback) PrepareMessage(org.apache.cassandra.repair.messages.PrepareMessage) Message(org.apache.cassandra.net.Message) CleanupMessage(org.apache.cassandra.repair.messages.CleanupMessage) RepairMessage(org.apache.cassandra.repair.messages.RepairMessage) CleanupMessage(org.apache.cassandra.repair.messages.CleanupMessage) NoSuchRepairSessionException(org.apache.cassandra.repair.NoSuchRepairSessionException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 RequestFailureReason (org.apache.cassandra.exceptions.RequestFailureReason)1 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)1 Message (org.apache.cassandra.net.Message)1 RequestCallback (org.apache.cassandra.net.RequestCallback)1 NoSuchRepairSessionException (org.apache.cassandra.repair.NoSuchRepairSessionException)1 CleanupMessage (org.apache.cassandra.repair.messages.CleanupMessage)1 PrepareMessage (org.apache.cassandra.repair.messages.PrepareMessage)1 RepairMessage (org.apache.cassandra.repair.messages.RepairMessage)1