public synchronized void registerParentRepairSession(UUID parentRepairSession, InetAddress coordinator, List<ColumnFamilyStore> columnFamilyStores, Collection<Range<Token>> ranges, boolean isIncremental, long timestamp, boolean isGlobal) { if (!registeredForEndpointChanges) { Gossiper.instance.register(this); FailureDetector.instance.registerFailureDetectionEventListener(this); registeredForEndpointChanges = true; } if (!parentRepairSessions.containsKey(parentRepairSession)) { parentRepairSessions.put(parentRepairSession, new ParentRepairSession(coordinator, columnFamilyStores, ranges, isIncremental, timestamp, isGlobal)); } }
/** * Mark sstables repairing - either all sstables or only the unrepaired ones depending on * * whether this is an incremental or full repair * * @param cfId the column family * @param parentSessionId the parent repair session id, used to make sure we don't start multiple repairs over the same sstables */ public synchronized void markSSTablesRepairing(UUID cfId, UUID parentSessionId) { if (!marked.contains(cfId)) { List<SSTableReader> sstables = columnFamilyStores.get(cfId).select(View.select(SSTableSet.CANONICAL, (s) -> !isIncremental || !s.isRepaired())).sstables; Set<SSTableReader> currentlyRepairing = ActiveRepairService.instance.currentlyRepairing(cfId, parentSessionId); if (!Sets.intersection(currentlyRepairing, Sets.newHashSet(sstables)).isEmpty()) { logger.error("Cannot start multiple repair sessions over the same sstables"); throw new RuntimeException("Cannot start multiple repair sessions over the same sstables"); } addSSTables(cfId, sstables); marked.add(cfId); } }
Refs<SSTableReader> sstables = prs.getActiveRepairedSSTableRefsForAntiCompaction(columnFamilyStoreEntry.getKey(), parentRepairSession); ColumnFamilyStore cfs = columnFamilyStoreEntry.getValue(); futures.add(CompactionManager.instance.submitAntiCompaction(cfs, successfulRanges, sstables, prs.repairedAt, parentRepairSession));
repairedAt = ActiveRepairService.instance.getParentRepairSession(parentSession).getRepairedAt(); progress.incrementAndGet();
repairedAt = ActiveRepairService.instance.getParentRepairSession(parentSession).getRepairedAt(); progress.incrementAndGet();
repairedAt = ActiveRepairService.instance.getParentRepairSession(parentSession).getRepairedAt(); progress.incrementAndGet();
if (prs.isGlobal) prs.maybeSnapshot(cfs.metadata.cfId, desc.parentSessionId); long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE; if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null) repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).getRepairedAt();
prs.markSSTablesRepairing(cfs.metadata.cfId, validator.desc.parentSessionId); sstables = cfs.selectAndReference(ColumnFamilyStore.UNREPAIRED_SSTABLES).refs;
if (prs.isGlobal) prs.maybeSnapshot(cfs.metadata.cfId, desc.parentSessionId); long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE; if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null) repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).getRepairedAt();
if (prs.isGlobal) prs.maybeSnapshot(cfs.metadata.cfId, desc.parentSessionId); long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE; if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null) repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).getRepairedAt();
Refs<SSTableReader> sstables = prs.getActiveRepairedSSTableRefsForAntiCompaction(columnFamilyStoreEntry.getKey(), parentRepairSession); ColumnFamilyStore cfs = columnFamilyStoreEntry.getValue(); futures.add(CompactionManager.instance.submitAntiCompaction(cfs, successfulRanges, sstables, prs.repairedAt, parentRepairSession));
Refs<SSTableReader> sstables = prs.getActiveRepairedSSTableRefsForAntiCompaction(columnFamilyStoreEntry.getKey(), parentRepairSession); ColumnFamilyStore cfs = columnFamilyStoreEntry.getValue(); futures.add(CompactionManager.instance.submitAntiCompaction(cfs, successfulRanges, sstables, prs.repairedAt, parentRepairSession));
private synchronized Refs<SSTableReader> getSSTablesToValidate(ColumnFamilyStore cfs, Validator validator) { Refs<SSTableReader> sstables; ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId); if (prs == null) return null; Set<SSTableReader> sstablesToValidate = new HashSet<>(); if (prs.isGlobal) prs.markSSTablesRepairing(cfs.metadata.cfId, validator.desc.parentSessionId); // note that we always grab all existing sstables for this - if we were to just grab the ones that // were marked as repairing, we would miss any ranges that were compacted away and this would cause us to overstream try (ColumnFamilyStore.RefViewFragment sstableCandidates = cfs.selectAndReference(View.select(SSTableSet.CANONICAL, (s) -> !prs.isIncremental || !s.isRepaired()))) { for (SSTableReader sstable : sstableCandidates.sstables) { if (new Bounds<>(sstable.first.getToken(), sstable.last.getToken()).intersects(validator.desc.ranges)) { sstablesToValidate.add(sstable); } } sstables = Refs.tryRef(sstablesToValidate); if (sstables == null) { logger.error("Could not reference sstables"); throw new RuntimeException("Could not reference sstables"); } } return sstables; }
boolean isSnapshotRepair = columnFamilyStores.get(cfId).snapshotExists(parentSessionId.toString()); ImmutableMap.Builder<SSTableReader, Ref<SSTableReader>> references = ImmutableMap.builder(); Iterable<SSTableReader> sstables = isSnapshotRepair ? getSSTablesForSnapshotRepair(cfId, parentSessionId) : getActiveSSTables(cfId);
private synchronized Refs<SSTableReader> getSSTablesToValidate(ColumnFamilyStore cfs, Validator validator) { Refs<SSTableReader> sstables; ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId); if (prs == null) return null; Set<SSTableReader> sstablesToValidate = new HashSet<>(); if (prs.isGlobal) prs.markSSTablesRepairing(cfs.metadata.cfId, validator.desc.parentSessionId); // note that we always grab all existing sstables for this - if we were to just grab the ones that // were marked as repairing, we would miss any ranges that were compacted away and this would cause us to overstream try (ColumnFamilyStore.RefViewFragment sstableCandidates = cfs.selectAndReference(View.select(SSTableSet.CANONICAL, (s) -> !prs.isIncremental || !s.isRepaired()))) { for (SSTableReader sstable : sstableCandidates.sstables) { if (new Bounds<>(sstable.first.getToken(), sstable.last.getToken()).intersects(validator.desc.ranges)) { sstablesToValidate.add(sstable); } } sstables = Refs.tryRef(sstablesToValidate); if (sstables == null) { logger.error("Could not reference sstables"); throw new RuntimeException("Could not reference sstables"); } } return sstables; }
boolean isSnapshotRepair = columnFamilyStores.get(cfId).snapshotExists(parentSessionId.toString()); ImmutableMap.Builder<SSTableReader, Ref<SSTableReader>> references = ImmutableMap.builder(); Iterable<SSTableReader> sstables = isSnapshotRepair ? getSSTablesForSnapshotRepair(cfId, parentSessionId) : getActiveSSTables(cfId);
/** * Submit anti-compaction jobs to CompactionManager. * When all jobs are done, parent repair session is removed whether those are suceeded or not. * * @param parentRepairSession parent repair session ID * @return Future result of all anti-compaction jobs. */ public ListenableFuture<List<Object>> doAntiCompaction(final UUID parentRepairSession) { assert parentRepairSession != null; ParentRepairSession prs = getParentRepairSession(parentRepairSession); List<ListenableFuture<?>> futures = new ArrayList<>(); for (Map.Entry<UUID, ColumnFamilyStore> columnFamilyStoreEntry : prs.columnFamilyStores.entrySet()) { Refs<SSTableReader> sstables = prs.getActiveRepairedSSTableRefsForAntiCompaction(columnFamilyStoreEntry.getKey()); ColumnFamilyStore cfs = columnFamilyStoreEntry.getValue(); futures.add(CompactionManager.instance.submitAntiCompaction(cfs, prs.ranges, sstables, prs.repairedAt)); } ListenableFuture<List<Object>> allAntiCompactionResults = Futures.successfulAsList(futures); allAntiCompactionResults.addListener(new Runnable() { @Override public void run() { removeParentRepairSession(parentRepairSession); } }, MoreExecutors.sameThreadExecutor()); return allAntiCompactionResults; }
private synchronized Refs<SSTableReader> getSSTablesToValidate(ColumnFamilyStore cfs, Validator validator) { Refs<SSTableReader> sstables; ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId); if (prs == null) return null; Set<SSTableReader> sstablesToValidate = new HashSet<>(); if (prs.isGlobal) prs.markSSTablesRepairing(cfs.metadata.cfId, validator.desc.parentSessionId); // note that we always grab all existing sstables for this - if we were to just grab the ones that // were marked as repairing, we would miss any ranges that were compacted away and this would cause us to overstream try (ColumnFamilyStore.RefViewFragment sstableCandidates = cfs.selectAndReference(View.select(SSTableSet.CANONICAL, (s) -> !prs.isIncremental || !s.isRepaired()))) { for (SSTableReader sstable : sstableCandidates.sstables) { if (new Bounds<>(sstable.first.getToken(), sstable.last.getToken()).intersects(validator.desc.ranges)) { sstablesToValidate.add(sstable); } } sstables = Refs.tryRef(sstablesToValidate); if (sstables == null) { logger.error("Could not reference sstables"); throw new RuntimeException("Could not reference sstables"); } } return sstables; }
boolean isSnapshotRepair = columnFamilyStores.get(cfId).snapshotExists(parentSessionId.toString()); ImmutableMap.Builder<SSTableReader, Ref<SSTableReader>> references = ImmutableMap.builder(); Iterable<SSTableReader> sstables = isSnapshotRepair ? getSSTablesForSnapshotRepair(cfId, parentSessionId) : getActiveSSTables(cfId);
/** * Gets the repairing sstables for anticompaction. * * Note that validation and streaming uses the real unrepaired sstables. * * @param cfId * @return */ @SuppressWarnings("resource") public synchronized Refs<SSTableReader> getActiveRepairedSSTableRefsForAntiCompaction(UUID cfId) { assert marked.contains(cfId); ImmutableMap.Builder<SSTableReader, Ref<SSTableReader>> references = ImmutableMap.builder(); Iterable<SSTableReader> sstables = getActiveSSTables(cfId); if (sstables == null) throw new RuntimeException("Not possible to get sstables for anticompaction for " + cfId); for (SSTableReader sstable : sstables) { Ref<SSTableReader> ref = sstable.tryRef(); if (ref == null) sstableMap.get(cfId).remove(sstable.getFilename()); else references.put(sstable, ref); } return new Refs<>(references.build()); }