public void refreshIndexList ( ) throws IOException { synchronized ( updateMonitor ) { // release reader if any releaseMultiReader ( ) ; // prepare added/removed sets Set < String > newList = new HashSet < String > ( indexNames . getNames ( ) ) ; // remove removed indexes Iterator < PersistentIndex > iterator = indexes . iterator ( ) ; while ( iterator . hasNext ( ) ) { PersistentIndex index = iterator . next ( ) ; String name = index . getName ( ) ; // if current index not in new list, close it, cause it is deleted. if ( ! newList . contains ( name ) ) { index . close ( ) ; iterator . remove ( ) ; } else { // remove from list, cause this segment of index still present and indexes list contains // PersistentIndex instance related to this index.. newList . remove ( name ) ; // Release everything to make sure that we see the // latest changes index . releaseWriterAndReaders ( ) ; } } // now newList contains ONLY new, added indexes, deleted indexes, are removed from list. for ( String name : newList ) { // only open if it still exists // it is possible that indexNames still contains a name for // an index that has been deleted, but indexNames has not been // written to disk. if ( ! directoryManager . hasDirectory ( name ) ) { LOG . debug ( "index does not exist anymore: " + name ) ; // move on to next index continue ; } PersistentIndex index = new PersistentIndex ( name , handler . getTextAnalyzer ( ) , handler . getSimilarity ( ) , cache , directoryManager , modeHandler ) ; index . setMaxFieldLength ( handler . getMaxFieldLength ( ) ) ; index . setUseCompoundFile ( handler . getUseCompoundFile ( ) ) ; index . setTermInfosIndexDivisor ( handler . getTermInfosIndexDivisor ( ) ) ; indexes . add ( index ) ; } // Reset the volatile index to be exactly like the master resetVolatileIndex ( ) ; } }
Refresh list of indexes . Used to be called asynchronously when list changes . New actual list is read from IndexInfos .