Search in sources :

Example 26 with TransactionRepresentation

use of org.neo4j.kernel.impl.transaction.TransactionRepresentation in project neo4j by neo4j.

the class PhysicalLogicalTransactionStoreTest method verifyTransaction.

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);
}
Also used : CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) TransactionMetadata(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache.TransactionMetadata)

Aggregations

TransactionRepresentation (org.neo4j.kernel.impl.transaction.TransactionRepresentation)26 Test (org.junit.Test)13 TransactionToApply (org.neo4j.kernel.impl.api.TransactionToApply)12 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)9 PhysicalTransactionRepresentation (org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)3 RequestContext (org.neo4j.com.RequestContext)3 LogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)3 LogEntryCommit (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)2 TransactionFailureException (org.neo4j.kernel.api.exceptions.TransactionFailureException)2 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)2 TransactionIdStore (org.neo4j.kernel.impl.transaction.log.TransactionIdStore)2 LogEntryStart (org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart)2 OnePhaseCommit (org.neo4j.kernel.impl.transaction.log.entry.OnePhaseCommit)2 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)2 StorageCommand (org.neo4j.storageengine.api.StorageCommand)2 ByteBuf (io.netty.buffer.ByteBuf)1