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;
}
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;
}
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();
}
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);
}
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;
}
Aggregations