void close ( boolean cleanCache ) { if ( ! this . closed ) { this . closed = true ; // Close storage reader (and thus cancel those reads). this . storageReadManager . close ( ) ; // Cancel registered future reads and any reads pertaining to incomplete mergers. ArrayList < Iterator < FutureReadResultEntry > > futureReads = new ArrayList <> ( ) ; futureReads . add ( this . futureReads . close ( ) . iterator ( ) ) ; synchronized ( this . lock ) { this . pendingMergers . values ( ) . forEach ( pm -> futureReads . add ( pm . seal ( ) . iterator ( ) ) ) ; } cancelFutureReads ( Iterators . concat ( futureReads . iterator ( ) ) ) ; if ( cleanCache ) { this . executor . execute ( ( ) -> { removeAllEntries ( ) ; log . info ( "{}: Closed." , this . traceObjectId ) ; } ) ; } else { log . info ( "{}: Closed (no cache cleanup)." , this . traceObjectId ) ; } } }
Closes the ReadIndex and optionally cleans the cache .