DirectoryReferenceCounter referenceCounter = new DirectoryReferenceCounter(directory, gc, closer);
// This directory allows for warm up by adding tracing ability.
TraceableDirectory dir = new TraceableDirectory(referenceCounter);
SimpleTimer simpleTimer = new SimpleTimer();
simpleTimer.start("writerOpen");
_writer = new BlurIndexWriter(dir, conf, true);
simpleTimer.stop("writerOpen");
simpleTimer.start("nrtSetup");
_recorder = new TransactionRecorder(shardContext);
_recorder.replay(_writer);
_searcherFactory = new SearcherFactory() {
@Override
public IndexSearcher newSearcher(IndexReader reader) throws IOException {
return new IndexSearcherClosableNRT(reader, searchExecutor, _nrtManagerRef, _directory);
}
};
_trackingWriter = new TrackingIndexWriter(_writer);
_indexImporter = new IndexImporter(_trackingWriter, _lock, _shardContext, TimeUnit.SECONDS, 10);
_nrtManagerRef.set(new NRTManager(_trackingWriter, _searcherFactory, APPLY_ALL_DELETES));
// start commiter
_committer = new Thread(new Committer());
_committer.setDaemon(true);
_committer.setName("Commit Thread [" + _tableContext.getTable() + "/" + shardContext.getShard() + "]");
_committer.start();
// start refresher
double targetMinStaleSec = _tableContext.getTimeBetweenRefreshs() / 1000.0;
_refresher = new NRTManagerReopenThread(getNRTManager(), targetMinStaleSec * 10, targetMinStaleSec);
_refresher.setName("Refresh Thread [" + _tableContext.getTable() + "/" + shardContext.getShard() + "]");
_refresher.setDaemon(true);
_refresher.start();
simpleTimer.stop("nrtSetup");
simpleTimer.log(LOG);
}