use of org.apache.cassandra.net.MessageIn in project cassandra by apache.
the class ActiveRepairService method prepareForRepair.
public UUID prepareForRepair(UUID parentRepairSession, InetAddress coordinator, Set<InetAddress> endpoints, RepairOption options, List<ColumnFamilyStore> columnFamilyStores) {
// we only want repairedAt for incremental repairs, for non incremental repairs, UNREPAIRED_SSTABLE will preserve repairedAt on streamed sstables
long repairedAt = options.isIncremental() ? Clock.instance.currentTimeMillis() : ActiveRepairService.UNREPAIRED_SSTABLE;
registerParentRepairSession(parentRepairSession, coordinator, columnFamilyStores, options.getRanges(), options.isIncremental(), repairedAt, options.isGlobal());
final CountDownLatch prepareLatch = new CountDownLatch(endpoints.size());
final AtomicBoolean status = new AtomicBoolean(true);
final Set<String> failedNodes = Collections.synchronizedSet(new HashSet<String>());
IAsyncCallbackWithFailure callback = new IAsyncCallbackWithFailure() {
public void response(MessageIn msg) {
prepareLatch.countDown();
}
public boolean isLatencyForSnitch() {
return false;
}
public void onFailure(InetAddress from, RequestFailureReason failureReason) {
status.set(false);
failedNodes.add(from.getHostAddress());
prepareLatch.countDown();
}
};
List<TableId> tableIds = new ArrayList<>(columnFamilyStores.size());
for (ColumnFamilyStore cfs : columnFamilyStores) tableIds.add(cfs.metadata.id);
for (InetAddress neighbour : endpoints) {
if (FailureDetector.instance.isAlive(neighbour)) {
PrepareMessage message = new PrepareMessage(parentRepairSession, tableIds, options.getRanges(), options.isIncremental(), repairedAt, options.isGlobal());
MessageOut<RepairMessage> msg = message.createMessage();
MessagingService.instance().sendRR(msg, neighbour, callback, DatabaseDescriptor.getRpcTimeout(), true);
} else {
status.set(false);
failedNodes.add(neighbour.getHostAddress());
prepareLatch.countDown();
}
}
try {
prepareLatch.await(DatabaseDescriptor.getRpcTimeout(), TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
removeParentRepairSession(parentRepairSession);
throw new RuntimeException("Did not get replies from all endpoints. List of failed endpoint(s): " + failedNodes, e);
}
if (!status.get()) {
removeParentRepairSession(parentRepairSession);
throw new RuntimeException("Did not get positive replies from all endpoints. List of failed endpoint(s): " + failedNodes);
}
return parentRepairSession;
}
Aggregations