@Override public TransactionMetadata getMetadataFor( long transactionId ) throws IOException { return physicalStore.getMetadataFor( transactionId ); }
@Test public void shouldThrowNoSuchTransactionExceptionIfMetadataNotFound() throws Exception { // GIVEN LogFiles logFiles = mock( LogFiles.class ); TransactionMetadataCache cache = new TransactionMetadataCache(); LifeSupport life = new LifeSupport(); final LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore( logFiles, cache, new VersionAwareLogEntryReader<>(), monitors, true ); try { life.start(); // WHEN try { txStore.getMetadataFor( 10 ); fail( "Should have thrown" ); } catch ( NoSuchTransactionException e ) { // THEN Good } } finally { life.shutdown(); } }
private void verifyTransaction( TransactionIdStore transactionIdStore, TransactionMetadataCache positionCache, byte[] additionalHeader, int masterId, int authorId, long timeStarted, long latestCommittedTxWhenStarted, long timeCommitted, LogicalTransactionStore store ) throws IOException { TransactionMetadata expectedMetadata; try ( TransactionCursor cursor = store.getTransactions( TransactionIdStore.BASE_TX_ID + 1 ) ) { boolean hasNext = cursor.next(); assertTrue( hasNext ); CommittedTransactionRepresentation tx = cursor.get(); TransactionRepresentation transaction = tx.getTransactionRepresentation(); assertArrayEquals( additionalHeader, transaction.additionalHeader() ); assertEquals( masterId, transaction.getMasterId() ); assertEquals( authorId, transaction.getAuthorId() ); assertEquals( timeStarted, transaction.getTimeStarted() ); assertEquals( timeCommitted, transaction.getTimeCommitted() ); assertEquals( latestCommittedTxWhenStarted, transaction.getLatestCommittedTxWhenStarted() ); expectedMetadata = new TransactionMetadata( masterId, authorId, tx.getStartEntry().getStartPosition(), tx.getStartEntry().checksum(), timeCommitted ); } positionCache.clear(); TransactionMetadata actualMetadata = store.getMetadataFor( transactionIdStore.getLastCommittedTransactionId() ); assertEquals( expectedMetadata, actualMetadata ); }
@Override public TransactionMetadata getMetadataFor( long transactionId ) throws IOException { return physicalStore.getMetadataFor( transactionId ); }