private boolean blockedStorageClose ( StorageType storageType ) { DB storage = storageRegistry . get ( storageType ) ; if ( isOpenStorage ( storage ) ) { storage . commit ( ) ; //find the underlying engine Engine e = storage . getEngine ( ) ; while ( EngineWrapper . class . isAssignableFrom ( e . getClass ( ) ) ) { e = ( ( EngineWrapper ) e ) . getWrappedEngine ( ) ; } //close and wait until the close on the underlying engine is also finished storage . close ( ) ; while ( ! e . isClosed ( ) ) { logger . trace ( "Waiting for the engine to close" ) ; try { TimeUnit . MILLISECONDS . sleep ( 100 ) ; } catch ( InterruptedException ex ) { throw new RuntimeException ( ex ) ; } } return true ; } else { return false ; } }
Closes the provided storage and waits until all changes are written to disk . It should be used when we move the storage to a different location . Returns true if the storage needed to be closed and false if it was not necessary .