public void commit ( ) { TxId txId = null ; // Check if in a higher transactional mode than none, otherwise commit does nothing. if ( ! getIsolationLevel ( ) . equals ( IsolationLevel . None ) ) { // Extract the current transaction id. txId = TxManager . getTxIdFromThread ( ) ; // Wait until the global write lock can be acquired by this transaction. try { acquireGlobalWriteLock ( txId ) ; } catch ( InterruptedException e ) { // The commit was interrupted, so cannot succeed. throw new IllegalStateException ( "Interrupted whilst commit is waiting for global write lock." , e ) ; } // Check that this transaction has made changes to be committed. List < TxOperation > alterations = txWrites . get ( txId ) ; try { if ( alterations != null ) { // Loop through all the writes that the transaction wants to apply to the resource. for ( TxOperation nextAlteration : alterations ) { // Apply the change and update the term resource. nextAlteration . execute ( ) ; } // Clear the write behind cache for this transaction as its work has been completed. txWrites . remove ( txId ) ; } } finally { // Release the global write lock. releaseGlobalWriteLock ( ) ; } } }
When operating in transactional mode causes any changes since the last commit to be made visible to the search method .