class IndexSamplingController {

    public void recoverIndexSamples()
    {
        samplingLock.lock();
        try
        {
            IndexMap indexMap = indexMapSnapshotProvider.indexMapSnapshot();
            final LongIterator indexIds = indexMap.indexIds();
            List<IndexSamplingJobHandle> asyncSamplingJobs = new ArrayList<>();
            while ( indexIds.hasNext() )
            {
                long indexId = indexIds.next();
                CapableIndexDescriptor descriptor = indexMap.getIndexProxy( indexId ).getDescriptor();
                if ( indexRecoveryCondition.test( descriptor ) )
                {
                    if ( logRecoverIndexSamples )
                    {
                        log.info( "Index requires sampling, id=%d, name=%s.", indexId, descriptor.getName() );
                    }

                    if ( asyncRecoverIndexSamples )
                    {
                        asyncSamplingJobs.add( sampleIndexOnTracker( indexMap, indexId ) );
                    }
                    else
                    {
                        sampleIndexOnCurrentThread( indexMap, indexId );
                    }
                }
                else
                {
                    if ( logRecoverIndexSamples )
                    {
                        log.info( "Index does not require sampling, id=%d, name=%s.", indexId, descriptor.getName() );
                    }
                }
            }
            if ( asyncRecoverIndexSamplesWait )
            {
                waitForAsyncIndexSamples( asyncSamplingJobs );
            }
        }
        finally
        {
            samplingLock.unlock();
        }
    }

      IndexSamplingController( IndexSamplingConfig config,
                             IndexSamplingJobFactory jobFactory,
                             IndexSamplingJobQueue<Long> jobQueue,
                             IndexSamplingJobTracker jobTracker,
                             IndexMapSnapshotProvider indexMapSnapshotProvider,
                             JobScheduler scheduler,
                             RecoveryCondition indexRecoveryCondition,
                             LogProvider logProvider );

}