use of org.apache.cassandra.net.IAsyncResult in project eiger by wlloyd.
the class RowRepairResolver method scheduleRepairs.
/**
* For each row version, compare with resolved (the superset of all row versions);
* if it is missing anything, send a mutation to the endpoint it come from.
*/
public static List<IAsyncResult> scheduleRepairs(ColumnFamily resolved, String table, DecoratedKey<?> key, List<ColumnFamily> versions, List<InetAddress> endpoints) {
List<IAsyncResult> results = new ArrayList<IAsyncResult>(versions.size());
for (int i = 0; i < versions.size(); i++) {
ColumnFamily diffCf = ColumnFamily.diff(versions.get(i), resolved);
if (// no repair needs to happen
diffCf == null)
continue;
// create and send the row mutation message based on the diff
RowMutation rowMutation = new RowMutation(table, key.key);
rowMutation.add(diffCf);
Message repairMessage;
try {
// use a separate verb here because we don't want these to be get the white glove hint-
// on-timeout behavior that a "real" mutation gets
repairMessage = rowMutation.getMessage(StorageService.Verb.READ_REPAIR, Gossiper.instance.getVersion(endpoints.get(i)));
} catch (IOException e) {
throw new IOError(e);
}
results.add(MessagingService.instance().sendRR(repairMessage, endpoints.get(i)));
}
return results;
}
use of org.apache.cassandra.net.IAsyncResult in project eiger by wlloyd.
the class StorageService method sendReplicationNotification.
/**
* Sends a notification to a node indicating we have finished replicating data.
*
* @param local the local address
* @param remote node to send notification to
*/
private void sendReplicationNotification(InetAddress local, InetAddress remote) {
// notify the remote token
Message msg = new Message(local, StorageService.Verb.REPLICATION_FINISHED, new byte[0], Gossiper.instance.getVersion(remote));
IFailureDetector failureDetector = FailureDetector.instance;
if (logger_.isDebugEnabled())
logger_.debug("Notifying " + remote.toString() + " of replication completion\n");
while (failureDetector.isAlive(remote)) {
IAsyncResult iar = MessagingService.instance().sendRR(msg, remote);
try {
iar.get(DatabaseDescriptor.getRpcTimeout(), TimeUnit.MILLISECONDS);
// done
return;
} catch (TimeoutException e) {
// try again
}
}
}
Aggregations