public void onRestart(InetAddress endpoint, EndpointState state) { convict(endpoint, Double.MAX_VALUE); }
/** * Compares other repairing sstables *generation* to the ones we just snapshotted * * we compare generations since the sstables have different paths due to snapshot names * * @param cfId id of the column family store * @param parentSessionId parent repair session * @param sstables the newly snapshotted sstables * @return */ private boolean isAlreadyRepairing(UUID cfId, UUID parentSessionId, Collection<SSTableReader> sstables) { Set<SSTableReader> currentlyRepairing = ActiveRepairService.instance.currentlyRepairing(cfId, parentSessionId); Set<Integer> currentlyRepairingGenerations = new HashSet<>(); Set<Integer> newRepairingGenerations = new HashSet<>(); for (SSTableReader sstable : currentlyRepairing) currentlyRepairingGenerations.add(sstable.descriptor.generation); for (SSTableReader sstable : sstables) newRepairingGenerations.add(sstable.descriptor.generation); return !Sets.intersection(currentlyRepairingGenerations, newRepairingGenerations).isEmpty(); }
@SuppressWarnings("unchecked") public ListenableFuture apply(List<RepairSessionResult> results) { // filter out null(=failed) results and get successful ranges for (RepairSessionResult sessionResult : results) { if (sessionResult != null) { successfulRanges.addAll(sessionResult.ranges); } else { hasFailure.compareAndSet(false, true); } } return ActiveRepairService.instance.finishParentSession(parentSession, allNeighbors, successfulRanges); } });
ActiveRepairService.instance.registerParentRepairSession(prepareMessage.parentRepairSession, message.from, columnFamilyStores, ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); if (prs.isGlobal) logger.debug("Syncing {}", request); long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE; if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null) repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).getRepairedAt(); AnticompactionRequest anticompactionRequest = (AnticompactionRequest) message.payload; logger.debug("Got anticompaction request {}", anticompactionRequest); ListenableFuture<?> compactionDone = ActiveRepairService.instance.doAntiCompaction(anticompactionRequest.parentRepairSession, anticompactionRequest.successfulRanges); compactionDone.addListener(new Runnable() logger.debug("cleaning up repair"); CleanupMessage cleanup = (CleanupMessage) message.payload; ActiveRepairService.instance.removeParentRepairSession(cleanup.parentRepairSession); MessagingService.instance().sendReply(new MessageOut(MessagingService.Verb.INTERNAL_RESPONSE), id, message.from); break; ActiveRepairService.instance.handleMessage(message.from, message.payload); break; ActiveRepairService.instance.removeParentRepairSession(desc.parentSessionId); throw new RuntimeException(e);
Set<InetAddress> neighbors = ActiveRepairService.getNeighbors(keyspace, keyspaceLocalRanges, range, options.getDataCenters(), options.getHosts()); try ActiveRepairService.instance.prepareForRepair(parentSession, FBUtilities.getBroadcastAddress(), allNeighbors, options, columnFamilyStores); repairedAt = ActiveRepairService.instance.getParentRepairSession(parentSession).getRepairedAt(); progress.incrementAndGet(); for (Pair<Set<InetAddress>, ? extends Collection<Range<Token>>> p : commonRanges) final RepairSession session = ActiveRepairService.instance.submitRepairSession(parentSession, p.right, keyspace,
Set<InetAddress> neighbors = ActiveRepairService.getNeighbors(keyspace, keyspaceLocalRanges, range, dataCenters, hosts); rangeToNeighbors.put(range, neighbors); allNeighbors.addAll(neighbors); parentSession = ActiveRepairService.instance.prepareForRepair(FBUtilities.getBroadcastAddress(), allNeighbors, ranges, columnFamilyStores); RepairFuture future = ActiveRepairService.instance.submitRepairSession(parentSession, range, keyspace, parallelismDegree, rangeToNeighbors.get(range), cfnames); if (future == null) continue; ListenableFuture future = ActiveRepairService.instance.finishParentSession(parentSession, allNeighbors, successful); future.addListener(new Runnable()
/** * called when the repair session is done - either failed or anticompaction has completed * * clears out any snapshots created by this repair * * @param parentSessionId * @return */ public synchronized ParentRepairSession removeParentRepairSession(UUID parentSessionId) { String snapshotName = parentSessionId.toString(); for (ColumnFamilyStore cfs : getParentRepairSession(parentSessionId).columnFamilyStores.values()) { if (cfs.snapshotExists(snapshotName)) cfs.clearSnapshot(snapshotName); } return parentRepairSessions.remove(parentSessionId); }
ParentRepairSession prs = getParentRepairSession(parentRepairSession); removeParentRepairSession(parentRepairSession); return Futures.immediateFuture(Collections.emptyList());
@Override public void run() { removeParentRepairSession(parentRepairSession); } }, MoreExecutors.directExecutor());
/** * 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 UUID prepareForRepair(UUID parentRepairSession, InetAddress coordinator, Set<InetAddress> endpoints, RepairOption options, List<ColumnFamilyStore> columnFamilyStores) registerParentRepairSession(parentRepairSession, coordinator, columnFamilyStores, options.getRanges(), options.isIncremental(), timestamp, options.isGlobal()); final CountDownLatch prepareLatch = new CountDownLatch(endpoints.size()); final AtomicBoolean status = new AtomicBoolean(true); failRepair(parentRepairSession, "Endpoint not alive: " + neighbour); failRepair(parentRepairSession, "Did not get replies from all endpoints."); failRepair(parentRepairSession, "Interrupted while waiting for prepare repair response."); failRepair(parentRepairSession, "Got negative replies from endpoints " + failedNodes);
/** * 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); }
RepairFuture submitArtificialRepairSession(RepairJobDesc desc) { Set<InetAddress> neighbours = new HashSet<>(); Collection<Range<Token>> keyspaceLocalRanges = StorageService.instance.getLocalRanges(desc.keyspace); neighbours.addAll(ActiveRepairService.getNeighbors(desc.keyspace, keyspaceLocalRanges, desc.range, null, null)); RepairSession session = new RepairSession(desc.parentSessionId, desc.sessionId, desc.range, desc.keyspace, RepairParallelism.PARALLEL, neighbours, new String[]{desc.columnFamily}); sessions.put(session.getId(), session); RepairFuture futureTask = new RepairFuture(session); executor.execute(futureTask); return futureTask; }
public synchronized UUID prepareForRepair(InetAddress coordinator, Set<InetAddress> endpoints, Collection<Range<Token>> ranges, List<ColumnFamilyStore> columnFamilyStores) registerParentRepairSession(parentRepairSession, coordinator, columnFamilyStores, ranges); final CountDownLatch prepareLatch = new CountDownLatch(endpoints.size()); final AtomicBoolean status = new AtomicBoolean(true);
ActiveRepairService.instance.registerParentRepairSession(prepareMessage.parentRepairSession, message.from, columnFamilyStores, ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); if (prs.isGlobal) logger.debug("Syncing {}", request); long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE; if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null) repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).getRepairedAt(); AnticompactionRequest anticompactionRequest = (AnticompactionRequest) message.payload; logger.debug("Got anticompaction request {}", anticompactionRequest); ListenableFuture<?> compactionDone = ActiveRepairService.instance.doAntiCompaction(anticompactionRequest.parentRepairSession, anticompactionRequest.successfulRanges); compactionDone.addListener(new Runnable() logger.debug("cleaning up repair"); CleanupMessage cleanup = (CleanupMessage) message.payload; ActiveRepairService.instance.removeParentRepairSession(cleanup.parentRepairSession); MessagingService.instance().sendReply(new MessageOut(MessagingService.Verb.INTERNAL_RESPONSE), id, message.from); break; ActiveRepairService.instance.handleMessage(message.from, message.payload); break; ActiveRepairService.instance.removeParentRepairSession(desc.parentSessionId); throw new RuntimeException(e);
Set<InetAddress> neighbors = ActiveRepairService.getNeighbors(keyspace, keyspaceLocalRanges, range, options.getDataCenters(), options.getHosts()); try ActiveRepairService.instance.prepareForRepair(parentSession, FBUtilities.getBroadcastAddress(), allNeighbors, options, columnFamilyStores); repairedAt = ActiveRepairService.instance.getParentRepairSession(parentSession).getRepairedAt(); progress.incrementAndGet(); for (Pair<Set<InetAddress>, ? extends Collection<Range<Token>>> p : commonRanges) final RepairSession session = ActiveRepairService.instance.submitRepairSession(parentSession, p.right, keyspace,
/** * called when the repair session is done - either failed or anticompaction has completed * * clears out any snapshots created by this repair * * @param parentSessionId * @return */ public synchronized ParentRepairSession removeParentRepairSession(UUID parentSessionId) { String snapshotName = parentSessionId.toString(); for (ColumnFamilyStore cfs : getParentRepairSession(parentSessionId).columnFamilyStores.values()) { if (cfs.snapshotExists(snapshotName)) cfs.clearSnapshot(snapshotName); } return parentRepairSessions.remove(parentSessionId); }
ParentRepairSession prs = getParentRepairSession(parentRepairSession); removeParentRepairSession(parentRepairSession); return Futures.immediateFuture(Collections.emptyList());
@Override public void run() { removeParentRepairSession(parentRepairSession); } }, MoreExecutors.directExecutor());
/** * 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); }