public Integer value() { return cfs.getCompactionStrategy().getEstimatedRemainingTasks(); } });
public Upgrader(ColumnFamilyStore cfs, SSTableReader sstable, OutputHandler outputHandler) { this.cfs = cfs; this.sstable = sstable; this.outputHandler = outputHandler; this.directory = new File(sstable.getFilename()).getParentFile(); this.controller = new UpgradeController(cfs); this.strategy = cfs.getCompactionStrategy(); long estimatedTotalKeys = Math.max(cfs.metadata.getMinIndexInterval(), SSTableReader.getApproximateKeyCount(Arrays.asList(this.sstable))); long estimatedSSTables = Math.max(1, SSTableReader.getTotalBytes(Arrays.asList(this.sstable)) / strategy.getMaxSSTableBytes()); this.estimatedRows = (long) Math.ceil((double) estimatedTotalKeys / estimatedSSTables); }
protected void runMayThrow() throws IOException { // look up the sstables now that we're on the compaction executor, so we don't try to re-compact // something that was already being compacted earlier. Collection<SSTableReader> sstables = new ArrayList<SSTableReader>(dataFiles.size()); for (Descriptor desc : dataFiles) { // inefficient but not in a performance sensitive path SSTableReader sstable = lookupSSTable(cfs, desc); if (sstable == null) { logger.info("Will not compact {}: it is not an active sstable", desc); } else { sstables.add(sstable); } } if (sstables.isEmpty()) { logger.info("No files to compact for user defined compaction"); } else { AbstractCompactionTask task = cfs.getCompactionStrategy().getUserDefinedTask(sstables, gcBefore); if (task != null) task.execute(metrics); } } };
final Collection<AbstractCompactionTask> tasks = cfStore.getCompactionStrategy().getMaximalTask(gcBefore);
@Override public void execute(SSTableReader input) throws IOException { AbstractCompactionTask task = cfs.getCompactionStrategy().getCompactionTask(Collections.singleton(input), NO_GC, Long.MAX_VALUE); task.setUserDefined(true); task.setCompactionType(OperationType.UPGRADE_SSTABLES); task.execute(metrics); } }, jobs);
public Integer value() { int n = 0; // add estimate number of compactions need to be done for (String keyspaceName : Schema.instance.getKeyspaces()) { for (ColumnFamilyStore cfs : Keyspace.open(keyspaceName).getColumnFamilyStores()) n += cfs.getCompactionStrategy().getEstimatedRemainingTasks(); } // add number of currently running compactions return n + compactions.size(); } });
public void dropCf(UUID cfId) { assert columnFamilyStores.containsKey(cfId); ColumnFamilyStore cfs = columnFamilyStores.remove(cfId); if (cfs == null) return; cfs.getCompactionStrategy().shutdown(); CompactionManager.instance.interruptCompactionForCFs(cfs.concatWithIndexes(), true); // wait for any outstanding reads/writes that might affect the CFS cfs.keyspace.writeOrder.awaitNewBarrier(); cfs.readOrdering.awaitNewBarrier(); unloadCf(cfs); }
cfs.getCompactionStrategy().pause(); try cfs.getCompactionStrategy().resume();
cfs.keyspace.getName(), cfs.name, cfs.getCompactionStrategy().getName()); List<Future<?>> futures = new ArrayList<>();
public void run() { try { logger.debug("Checking {}.{}", cfs.keyspace.getName(), cfs.name); if (!cfs.isValid()) { logger.debug("Aborting compaction for dropped CF"); return; } AbstractCompactionStrategy strategy = cfs.getCompactionStrategy(); AbstractCompactionTask task = strategy.getNextBackgroundTask(getDefaultGcBefore(cfs)); if (task == null) { logger.debug("No tasks available"); return; } task.execute(metrics); } finally { compactingCF.remove(cfs); } submitBackground(cfs); } }
checkManifest(cfs.getCompactionStrategy(), cfs, sstables); CompactionManager.instance.finishCompactionsAndShutdown(5, TimeUnit.MINUTES); SSTableDeletingTask.waitForDeletions();
SSTableRewriter unRepairedSSTableWriter = new SSTableRewriter(cfs, sstableAsSet, sstable.maxDataAge, false, false); try (AbstractCompactionStrategy.ScannerList scanners = cfs.getCompactionStrategy().getScanners(new HashSet<>(Collections.singleton(sstable))); CompactionController controller = new CompactionController(cfs, sstableAsSet, getDefaultGcBefore(cfs)))
private static void checkManifest(AbstractCompactionStrategy strategy, ColumnFamilyStore cfs, Collection<SSTableReader> sstables) { WrappingCompactionStrategy wrappingStrategy = (WrappingCompactionStrategy)strategy; int maxSizeInMB = (int)((cfs.getCompactionStrategy().getMaxSSTableBytes()) / (1024L * 1024L)); if (wrappingStrategy.getWrappedStrategies().size() == 2 && wrappingStrategy.getWrappedStrategies().iterator().next() instanceof LeveledCompactionStrategy) { System.out.println("Checking leveled manifest"); Predicate<SSTableReader> repairedPredicate = new Predicate<SSTableReader>() { @Override public boolean apply(SSTableReader sstable) { return sstable.isRepaired(); } }; List<SSTableReader> repaired = Lists.newArrayList(Iterables.filter(sstables, repairedPredicate)); List<SSTableReader> unRepaired = Lists.newArrayList(Iterables.filter(sstables, Predicates.not(repairedPredicate))); LeveledManifest repairedManifest = LeveledManifest.create(cfs, maxSizeInMB, repaired); for (int i = 1; i < repairedManifest.getLevelCount(); i++) { repairedManifest.repairOverlappingSSTables(i); } LeveledManifest unRepairedManifest = LeveledManifest.create(cfs, maxSizeInMB, unRepaired); for (int i = 1; i < unRepairedManifest.getLevelCount(); i++) { unRepairedManifest.repairOverlappingSSTables(i); } } }
if (logger.isDebugEnabled()) logger.debug("Compaction candidates for L{} are {}", i, toString(candidates)); return new CompactionCandidate(candidates, nextLevel, cfs.getCompactionStrategy().getMaxSSTableBytes()); return new CompactionCandidate(candidates, getNextLevel(candidates), cfs.getCompactionStrategy().getMaxSSTableBytes());
if (store.getCompactionStrategy().shouldBeEnabled()) store.enableAutoCompaction();
AbstractCompactionStrategy strategy = cfs.getCompactionStrategy(); try if (!controller.cfs.getCompactionStrategy().isActive) throw new CompactionInterruptedException(ci.getCompactionInfo()); if (!iter.hasNext())
try (AbstractCompactionStrategy.ScannerList scanners = cfs.getCompactionStrategy().getScanners(sstables, validator.desc.range))
&& onlyUnrepaired && !cfs.isAutoCompactionDisabled() && cfs.getCompactionStrategy().shouldDefragment())