use of org.apache.cassandra.net.IAsyncCallback in project cassandra by apache.
the class MigrationTask method runMayThrow.
public void runMayThrow() throws Exception {
// a higher major.
if (!MigrationManager.shouldPullSchemaFrom(endpoint)) {
logger.info("Skipped sending a migration request: node {} has a higher major version now.", endpoint);
return;
}
if (!FailureDetector.instance.isAlive(endpoint)) {
logger.debug("Can't send schema pull request: node {} is down.", endpoint);
return;
}
MessageOut message = new MessageOut<>(MessagingService.Verb.MIGRATION_REQUEST, null, MigrationManager.MigrationsSerializer.instance);
final CountDownLatch completionLatch = new CountDownLatch(1);
IAsyncCallback<Collection<Mutation>> cb = new IAsyncCallback<Collection<Mutation>>() {
@Override
public void response(MessageIn<Collection<Mutation>> message) {
try {
Schema.instance.mergeAndAnnounceVersion(message.payload);
} catch (ConfigurationException e) {
logger.error("Configuration exception merging remote schema", e);
} finally {
completionLatch.countDown();
}
}
public boolean isLatencyForSnitch() {
return false;
}
};
// Only save the latches if we need bootstrap or are bootstrapping
if (monitoringBootstrapStates.contains(SystemKeyspace.getBootstrapState()))
inflightTasks.offer(completionLatch);
MessagingService.instance().sendRR(message, endpoint, cb);
}
use of org.apache.cassandra.net.IAsyncCallback in project cassandra by apache.
the class Gossiper method markAlive.
private void markAlive(final InetAddress addr, final EndpointState localState) {
localState.markDead();
MessageOut<EchoMessage> echoMessage = new MessageOut<EchoMessage>(MessagingService.Verb.ECHO, EchoMessage.instance, EchoMessage.serializer);
logger.trace("Sending a EchoMessage to {}", addr);
IAsyncCallback echoHandler = new IAsyncCallback() {
public boolean isLatencyForSnitch() {
return false;
}
public void response(MessageIn msg) {
realMarkAlive(addr, localState);
}
};
MessagingService.instance().sendRR(echoMessage, addr, echoHandler);
}
Aggregations