src/java/org/apache/cassandra/db/compaction/CompactionManager.java
/**
     * Performs a readonly "compaction" of all sstables in order to validate complete rows,
     * but without writing the merge result
     */
Performs a readonly "compaction" of all sstables in order to validate complete rows,
but without writing the merge result
Performs a readonly " compaction " of all sstables in order to validate complete rows but without writing the merge result
private void doValidationCompaction(ColumnFamilyStore cfs, AntiEntropyService.Validator validator) throws IOException
    {
        if (!cfs.isValid())
            return;
        try
        {
            StorageService.instance.forceTableFlush(cfs.table.name, cfs.getColumnFamilyName());
        }
        catch (ExecutionException e)
        {
            throw new IOException(e);
        }
        catch (InterruptedException e)
        {
            throw new AssertionError(e);
        }
        Collection<SSTableReader> sstables = cfs.markCurrentSSTablesReferenced();
        CompactionIterable ci = new ValidationCompactionIterable(cfs, sstables, validator.request.range);
        CloseableIterator<AbstractCompactedRow> iter = ci.iterator();
        validationExecutor.beginCompaction(ci);
        try
        {
            Iterator<AbstractCompactedRow> nni = Iterators.filter(iter, Predicates.notNull());
            validator.prepare(cfs);
            while (nni.hasNext())
            {
                if (ci.isStopped())
                    throw new CompactionInterruptedException(ci.getCompactionInfo());
                AbstractCompactedRow row = nni.next();
                validator.add(row);
            }
            validator.complete();
        }
        finally
        {
            SSTableReader.releaseReferences(sstables);
            iter.close();
            validationExecutor.finishCompaction(ci);
        }
    }
private void doValidationCompaction ( ColumnFamilyStore cfs , AntiEntropyService . Validator validator ) throws IOException { if ( ! cfs . isValid ( ) ) return ; try { StorageService . instance . forceTableFlush ( cfs . table . name , cfs . getColumnFamilyName ( ) ) ; } catch ( ExecutionException e ) { throw new IOException ( e ) ; } catch ( InterruptedException e ) { throw new AssertionError ( e ) ; } Collection < SSTableReader > sstables = cfs . markCurrentSSTablesReferenced ( ) ; CompactionIterable ci = new ValidationCompactionIterable ( cfs , sstables , validator . request . range ) ; CloseableIterator < AbstractCompactedRow > iter = ci . iterator ( ) ; validationExecutor . beginCompaction ( ci ) ; try { Iterator < AbstractCompactedRow > nni = Iterators . filter ( iter , Predicates . notNull ( ) ) ; validator . prepare ( cfs ) ; while ( nni . hasNext ( ) ) { if ( ci . isStopped ( ) ) throw new CompactionInterruptedException ( ci . getCompactionInfo ( ) ) ; AbstractCompactedRow row = nni . next ( ) ; validator . add ( row ) ; } validator . complete ( ) ; } finally { SSTableReader . releaseReferences ( sstables ) ; iter . close ( ) ; validationExecutor . finishCompaction ( ci ) ; } }
Performs a readonly "compaction" of all sstables in order to validate complete rows,
 but without writing the merge result
Performs a readonly " compaction " of all sstables in order to validate complete rows but without writing the merge result
// this isn't meant to be race-proof, because it's not -- it won't cause bugs for a CFS to be dropped // mid-validation, or to attempt to validate a droped CFS.  this is just a best effort to avoid useless work, // particularly in the scenario where a validation is submitted before the drop, and there are compactions // started prior to the drop keeping some sstables alive.  Since validationCompaction can run // concurrently with other compactions, it would otherwise go ahead and scan those again. // flush first so everyone is validating data that is as similar as possible // we don't mark validating sstables as compacting in DataTracker, so we have to mark them referenced // instead so they won't be cleaned up if they do get compacted during the validation // validate the CF as we iterate over it