private boolean maybeSetResult(InetAddress o) { if (isFinished.compareAndSet(false, true)) { set(o); return true; } return false; }
private boolean maybeSetException(Throwable t) { if (isFinished.compareAndSet(false, true)) { setException(t); return true; } return false; }
public void onRemove(InetAddress endpoint) { convict(endpoint, Double.MAX_VALUE); }
/** * Run final process of repair. * This removes all resources held by parent repair session, after performing anti compaction if necessary. * * @param parentSession Parent session ID * @param neighbors Repair participants (not including self) * @param successfulRanges Ranges that repaired successfully */ public synchronized ListenableFuture finishParentSession(UUID parentSession, Set<InetAddress> neighbors, Collection<Range<Token>> successfulRanges) { List<ListenableFuture<?>> tasks = new ArrayList<>(neighbors.size() + 1); for (InetAddress neighbor : neighbors) { AnticompactionTask task = new AnticompactionTask(parentSession, neighbor, successfulRanges); registerOnFdAndGossip(task); tasks.add(task); task.run(); // 'run' is just sending message } tasks.add(doAntiCompaction(parentSession, successfulRanges)); return Futures.successfulAsList(tasks); }
public void run() { if (FailureDetector.instance.isAlive(neighbor)) { AnticompactionRequest acr = new AnticompactionRequest(parentSession); SemanticVersion peerVersion = SystemKeyspace.getReleaseVersion(neighbor); if (peerVersion != null && peerVersion.compareTo(VERSION_CHECKER) > 0) { if (doAnticompaction) { MessagingService.instance().sendRR(acr.createMessage(), neighbor, new AnticompactionCallback(this), TimeUnit.DAYS.toMillis(1), true); } else { // we need to clean up parent session MessagingService.instance().sendRR(new CleanupMessage(parentSession).createMessage(), neighbor, new AnticompactionCallback(this), TimeUnit.DAYS.toMillis(1), true); } } else { MessagingService.instance().sendOneWay(acr.createMessage(), neighbor); // immediately return after sending request set(neighbor); } } else { setException(new IOException(neighbor + " is down")); } }
public void run() { if (FailureDetector.instance.isAlive(neighbor)) { AnticompactionRequest acr = new AnticompactionRequest(parentSession, successfulRanges); CassandraVersion peerVersion = SystemKeyspace.getReleaseVersion(neighbor); if (peerVersion != null && peerVersion.compareTo(VERSION_CHECKER) > 0) { MessagingService.instance().sendRR(acr.createMessage(), neighbor, new AnticompactionCallback(this), TimeUnit.DAYS.toMillis(1), true); } else { // immediately return after sending request MessagingService.instance().sendOneWay(acr.createMessage(), neighbor); maybeSetResult(neighbor); } } else { maybeSetException(new IOException(neighbor + " is down")); } }
public void convict(InetAddress endpoint, double phi) { if (!neighbor.equals(endpoint)) return; // We want a higher confidence in the failure detection than usual because failing a repair wrongly has a high cost. if (phi < 2 * DatabaseDescriptor.getPhiConvictThreshold()) return; Exception exception = new IOException(String.format("Endpoint %s died during anti-compaction.", endpoint)); if (maybeSetException(exception)) { // Though unlikely, it is possible to arrive here multiple time and we want to avoid print an error message twice logger.error("[repair #{}] Endpoint {} died during anti-compaction", endpoint, parentSession, exception); } } }
/** * Run final process of repair. * This removes all resources held by parent repair session, after performing anti compaction if necessary. * * @param parentSession Parent session ID * @param neighbors Repair participants (not including self) * @param successfulRanges Ranges that repaired successfully */ public synchronized ListenableFuture finishParentSession(UUID parentSession, Set<InetAddress> neighbors, Collection<Range<Token>> successfulRanges) { List<ListenableFuture<?>> tasks = new ArrayList<>(neighbors.size() + 1); for (InetAddress neighbor : neighbors) { AnticompactionTask task = new AnticompactionTask(parentSession, neighbor, successfulRanges); registerOnFdAndGossip(task); tasks.add(task); task.run(); // 'run' is just sending message } tasks.add(doAntiCompaction(parentSession, successfulRanges)); return Futures.successfulAsList(tasks); }
public void run() { if (FailureDetector.instance.isAlive(neighbor)) { AnticompactionRequest acr = new AnticompactionRequest(parentSession, successfulRanges); CassandraVersion peerVersion = SystemKeyspace.getReleaseVersion(neighbor); if (peerVersion != null && peerVersion.compareTo(VERSION_CHECKER) > 0) { MessagingService.instance().sendRR(acr.createMessage(), neighbor, new AnticompactionCallback(this), TimeUnit.DAYS.toMillis(1), true); } else { // immediately return after sending request MessagingService.instance().sendOneWay(acr.createMessage(), neighbor); maybeSetResult(neighbor); } } else { maybeSetException(new IOException(neighbor + " is down")); } }
public void convict(InetAddress endpoint, double phi) { if (!neighbor.equals(endpoint)) return; // We want a higher confidence in the failure detection than usual because failing a repair wrongly has a high cost. if (phi < 2 * DatabaseDescriptor.getPhiConvictThreshold()) return; Exception exception = new IOException(String.format("Endpoint %s died during anti-compaction.", endpoint)); if (maybeSetException(exception)) { // Though unlikely, it is possible to arrive here multiple time and we want to avoid print an error message twice logger.error("[repair #{}] Endpoint {} died during anti-compaction", endpoint, parentSession, exception); } } }
/** * Run final process of repair. * This removes all resources held by parent repair session, after performing anti compaction if necessary. * * @param parentSession Parent session ID * @param neighbors Repair participants (not including self) * @param successfulRanges Ranges that repaired successfully */ public synchronized ListenableFuture finishParentSession(UUID parentSession, Set<InetAddress> neighbors, Collection<Range<Token>> successfulRanges) { List<ListenableFuture<?>> tasks = new ArrayList<>(neighbors.size() + 1); for (InetAddress neighbor : neighbors) { AnticompactionTask task = new AnticompactionTask(parentSession, neighbor, successfulRanges); registerOnFdAndGossip(task); tasks.add(task); task.run(); // 'run' is just sending message } tasks.add(doAntiCompaction(parentSession, successfulRanges)); return Futures.successfulAsList(tasks); }
public void run() { if (FailureDetector.instance.isAlive(neighbor)) { AnticompactionRequest acr = new AnticompactionRequest(parentSession, successfulRanges); CassandraVersion peerVersion = SystemKeyspace.getReleaseVersion(neighbor); if (peerVersion != null && peerVersion.compareTo(VERSION_CHECKER) > 0) { MessagingService.instance().sendRR(acr.createMessage(), neighbor, new AnticompactionCallback(this), TimeUnit.DAYS.toMillis(1), true); } else { // immediately return after sending request MessagingService.instance().sendOneWay(acr.createMessage(), neighbor); maybeSetResult(neighbor); } } else { maybeSetException(new IOException(neighbor + " is down")); } }
public void onRestart(InetAddress endpoint, EndpointState epState) { convict(endpoint, Double.MAX_VALUE); }
private boolean maybeSetResult(InetAddress o) { if (isFinished.compareAndSet(false, true)) { set(o); return true; } return false; }
private boolean maybeSetException(Throwable t) { if (isFinished.compareAndSet(false, true)) { setException(t); return true; } return false; }
public void convict(InetAddress endpoint, double phi) { if (!neighbor.equals(endpoint)) return; // We want a higher confidence in the failure detection than usual because failing a repair wrongly has a high cost. if (phi < 2 * DatabaseDescriptor.getPhiConvictThreshold()) return; Exception exception = new IOException(String.format("Endpoint %s died during anti-compaction.", endpoint)); if (maybeSetException(exception)) { // Though unlikely, it is possible to arrive here multiple time and we want to avoid print an error message twice logger.error("[repair #{}] Endpoint {} died during anti-compaction", endpoint, parentSession, exception); } } }
/** * Run final process of repair. * This removes all resources held by parent repair session, after performing anti compaction if necessary. * * @param parentSession Parent session ID * @param neighbors Repair participants (not including self) * @throws InterruptedException * @throws ExecutionException */ public synchronized ListenableFuture<?> finishParentSession(UUID parentSession, Set<InetAddress> neighbors, boolean doAntiCompaction) throws InterruptedException, ExecutionException { // We want to remove parent repair session whether we succeeded or not, so send AnticompactionRequest anyway. // Each replica node determines if anticompaction is needed. List<ListenableFuture<?>> tasks = new ArrayList<>(neighbors.size() + 1); for (InetAddress neighbor : neighbors) { AnticompactionTask task = new AnticompactionTask(parentSession, neighbor, doAntiCompaction); tasks.add(task); task.run(); // 'run' is just sending message } if (doAntiCompaction) { tasks.add(doAntiCompaction(parentSession)); } else { removeParentRepairSession(parentSession); } return Futures.successfulAsList(tasks); }
public void onRestart(InetAddress endpoint, EndpointState epState) { convict(endpoint, Double.MAX_VALUE); }
private boolean maybeSetResult(InetAddress o) { if (isFinished.compareAndSet(false, true)) { set(o); return true; } return false; }
private boolean maybeSetException(Throwable t) { if (isFinished.compareAndSet(false, true)) { setException(t); return true; } return false; }