@Override public void shutdown() { disposeAll(); }
private void clearTransactions() { // We don't want to have buffered ids carry over to the new role storageEngine.clearBufferedIds(); // Get rid of all pooled transactions, as they will otherwise reference // components that have been swapped out during the mode switch. kernelModule.kernelTransactions().disposeAll(); }
@Test public void transactionClosesUnderlyingStoreReaderWhenDisposed() throws Throwable { StorageReader storeStatement1 = mock( StorageReader.class ); StorageReader storeStatement2 = mock( StorageReader.class ); StorageReader storeStatement3 = mock( StorageReader.class ); KernelTransactions kernelTransactions = newKernelTransactions( mock( TransactionCommitProcess.class ), storeStatement1, storeStatement2, storeStatement3 ); // start and close 3 transactions from different threads startAndCloseTransaction( kernelTransactions ); Executors.newSingleThreadExecutor().submit( () -> startAndCloseTransaction( kernelTransactions ) ).get(); Executors.newSingleThreadExecutor().submit( () -> startAndCloseTransaction( kernelTransactions ) ).get(); kernelTransactions.disposeAll(); verify( storeStatement1 ).close(); verify( storeStatement2 ).close(); verify( storeStatement3 ).close(); }
@Test public void shouldDisposeTransactionsWhenAsked() throws Throwable { // Given KernelTransactions transactions = newKernelTransactions(); transactions.disposeAll(); KernelTransaction first = getKernelTransaction( transactions ); KernelTransaction second = getKernelTransaction( transactions ); KernelTransaction leftOpen = getKernelTransaction( transactions ); first.close(); second.close(); // When transactions.disposeAll(); // Then KernelTransaction postDispose = getKernelTransaction( transactions ); assertThat( postDispose, not( equalTo( first ) ) ); assertThat( postDispose, not( equalTo( second ) ) ); assertNotNull( leftOpen.getReasonIfTerminated() ); }
@Test public void disposeAllMarksAllTransactionsForTermination() throws Throwable { KernelTransactions kernelTransactions = newKernelTransactions(); KernelTransaction tx1 = getKernelTransaction( kernelTransactions ); KernelTransaction tx2 = getKernelTransaction( kernelTransactions ); KernelTransaction tx3 = getKernelTransaction( kernelTransactions ); kernelTransactions.disposeAll(); assertEquals( Status.General.DatabaseUnavailable, tx1.getReasonIfTerminated().get() ); assertEquals( Status.General.DatabaseUnavailable, tx2.getReasonIfTerminated().get() ); assertEquals( Status.General.DatabaseUnavailable, tx3.getReasonIfTerminated().get() ); }
@Override public void shutdown() { disposeAll(); }
private void clearTransactions() { // We don't want to have buffered ids carry over to the new role storageEngine.clearBufferedIds(); // Get rid of all pooled transactions, as they will otherwise reference // components that have been swapped out during the mode switch. kernelModule.kernelTransactions().disposeAll(); }