Search in sources :

Example 11 with TransactionCursor

use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.

the class LabelAndIndexUpdateBatchingIT method extractTransactions.

private static List<TransactionRepresentation> extractTransactions(GraphDatabaseAPI db) throws NoSuchTransactionException, IOException {
    LogicalTransactionStore txStore = db.getDependencyResolver().resolveDependency(LogicalTransactionStore.class);
    List<TransactionRepresentation> transactions = new ArrayList<>();
    try (TransactionCursor cursor = txStore.getTransactions(TransactionIdStore.BASE_TX_ID + 1)) {
        cursor.forAll(tx -> transactions.add(tx.getTransactionRepresentation()));
    }
    return transactions;
}
Also used : TransactionCursor(org.neo4j.kernel.impl.transaction.log.TransactionCursor) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) ArrayList(java.util.ArrayList) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)

Example 12 with TransactionCursor

use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.

the class RecoverIndexDropIT method extractLastTransaction.

private static CommittedTransactionRepresentation extractLastTransaction(GraphDatabaseAPI db) throws IOException {
    LogicalTransactionStore txStore = db.getDependencyResolver().resolveDependency(LogicalTransactionStore.class);
    CommittedTransactionRepresentation transaction = null;
    try (TransactionCursor cursor = txStore.getTransactions(TransactionIdStore.BASE_TX_ID + 1)) {
        while (cursor.next()) {
            transaction = cursor.get();
        }
    }
    return transaction;
}
Also used : CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) TransactionCursor(org.neo4j.kernel.impl.transaction.log.TransactionCursor) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)

Example 13 with TransactionCursor

use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.

the class RecoveryProgressIndicatorTest method reportProgressOnRecovery.

@Test
void reportProgressOnRecovery() throws Throwable {
    RecoveryService recoveryService = mock(RecoveryService.class, Answers.RETURNS_MOCKS);
    CorruptedLogsTruncator logsTruncator = mock(CorruptedLogsTruncator.class);
    RecoveryMonitor recoveryMonitor = mock(RecoveryMonitor.class);
    TransactionCursor reverseTransactionCursor = mock(TransactionCursor.class);
    TransactionCursor transactionCursor = mock(TransactionCursor.class);
    CommittedTransactionRepresentation transactionRepresentation = mock(CommittedTransactionRepresentation.class);
    int transactionsToRecover = 5;
    int expectedMax = transactionsToRecover * 2;
    int lastCommittedTransactionId = 14;
    LogPosition transactionLogPosition = new LogPosition(0, CURRENT_FORMAT_LOG_HEADER_SIZE);
    LogPosition checkpointLogPosition = new LogPosition(0, CURRENT_FORMAT_LOG_HEADER_SIZE);
    int firstTxIdAfterLastCheckPoint = 10;
    RecoveryStartInformation startInformation = new RecoveryStartInformation(transactionLogPosition, checkpointLogPosition, firstTxIdAfterLastCheckPoint);
    when(reverseTransactionCursor.next()).thenAnswer(new NextTransactionAnswer(transactionsToRecover));
    when(transactionCursor.next()).thenAnswer(new NextTransactionAnswer(transactionsToRecover));
    when(reverseTransactionCursor.get()).thenReturn(transactionRepresentation);
    when(transactionCursor.get()).thenReturn(transactionRepresentation);
    when(transactionRepresentation.getCommitEntry()).thenReturn(new LogEntryCommit(lastCommittedTransactionId, 1L, BASE_TX_CHECKSUM));
    when(recoveryService.getRecoveryStartInformation()).thenReturn(startInformation);
    when(recoveryService.getTransactionsInReverseOrder(transactionLogPosition)).thenReturn(reverseTransactionCursor);
    when(recoveryService.getTransactions(transactionLogPosition)).thenReturn(transactionCursor);
    AssertableProgressReporter progressReporter = new AssertableProgressReporter(expectedMax);
    TransactionLogsRecovery recovery = new TransactionLogsRecovery(recoveryService, logsTruncator, new LifecycleAdapter(), recoveryMonitor, progressReporter, true, EMPTY_CHECKER, PageCacheTracer.NULL);
    recovery.init();
    progressReporter.verify();
}
Also used : CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter) TransactionCursor(org.neo4j.kernel.impl.transaction.log.TransactionCursor) LogEntryCommit(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.jupiter.api.Test)

Example 14 with TransactionCursor

use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.

the class ReversedMultiFileTransactionCursorTest method shouldReadMultipleVersionsReversed.

@Test
void shouldReadMultipleVersionsReversed() throws Exception {
    // GIVEN
    TransactionCursor cursor = new ReversedMultiFileTransactionCursor(logFile, log(5, 3, 8), 2, start());
    // WHEN
    CommittedTransactionRepresentation[] reversed = exhaust(cursor);
    // THEN
    assertTransactionRange(reversed, 5 + 3 + 8, 0);
}
Also used : CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) TransactionCursor(org.neo4j.kernel.impl.transaction.log.TransactionCursor) Test(org.junit.jupiter.api.Test)

Example 15 with TransactionCursor

use of org.neo4j.kernel.impl.transaction.log.TransactionCursor in project neo4j by neo4j.

the class LabelAndIndexUpdateBatchingIT method extractTransactions.

private static List<TransactionRepresentation> extractTransactions(GraphDatabaseAPI db, long txIdToStartOn) throws IOException {
    LogicalTransactionStore txStore = db.getDependencyResolver().resolveDependency(LogicalTransactionStore.class);
    List<TransactionRepresentation> transactions = new ArrayList<>();
    try (TransactionCursor cursor = txStore.getTransactions(txIdToStartOn)) {
        cursor.forAll(tx -> transactions.add(tx.getTransactionRepresentation()));
    }
    return transactions;
}
Also used : TransactionCursor(org.neo4j.kernel.impl.transaction.log.TransactionCursor) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) ArrayList(java.util.ArrayList) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)

Aggregations

TransactionCursor (org.neo4j.kernel.impl.transaction.log.TransactionCursor)15 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)13 Test (org.junit.jupiter.api.Test)6 LogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore)6 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 TransactionRepresentation (org.neo4j.kernel.impl.transaction.TransactionRepresentation)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Test (org.junit.Test)1 AfterEach (org.junit.jupiter.api.AfterEach)1 Response (org.neo4j.com.Response)1 Visitor (org.neo4j.helpers.collection.Visitor)1 Command (org.neo4j.internal.recordstorage.Command)1 KernelVersion (org.neo4j.kernel.KernelVersion)1 DeadSimpleTransactionIdStore (org.neo4j.kernel.impl.transaction.DeadSimpleTransactionIdStore)1 NoSuchTransactionException (org.neo4j.kernel.impl.transaction.log.NoSuchTransactionException)1 PhysicalTransactionRepresentation (org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation)1 ReadOnlyTransactionIdStore (org.neo4j.kernel.impl.transaction.log.ReadOnlyTransactionIdStore)1 ReadOnlyTransactionStore (org.neo4j.kernel.impl.transaction.log.ReadOnlyTransactionStore)1