use of org.neo4j.kernel.recovery.TransactionLogsRecovery in project neo4j by neo4j.
the class PhysicalLogicalTransactionStoreTest method shouldOpenAndRecoverExistingData.
@Test
void shouldOpenAndRecoverExistingData() throws Exception {
// GIVEN
TransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
TransactionMetadataCache positionCache = new TransactionMetadataCache();
final byte[] additionalHeader = new byte[] { 1, 2, 5 };
final long timeStarted = 12345;
long latestCommittedTxWhenStarted = 4545;
long timeCommitted = timeStarted + 10;
LifeSupport life = new LifeSupport();
final LogFiles logFiles = buildLogFiles(transactionIdStore);
life.start();
life.add(logFiles);
try {
addATransactionAndRewind(life, logFiles, positionCache, transactionIdStore, additionalHeader, timeStarted, latestCommittedTxWhenStarted, timeCommitted);
} finally {
life.shutdown();
}
life = new LifeSupport();
life.add(logFiles);
final AtomicBoolean recoveryPerformed = new AtomicBoolean();
FakeRecoveryVisitor visitor = new FakeRecoveryVisitor(additionalHeader, timeStarted, timeCommitted, latestCommittedTxWhenStarted);
LogicalTransactionStore txStore = new PhysicalLogicalTransactionStore(logFiles, positionCache, logEntryReader(), monitors, true);
life.add(new BatchingTransactionAppender(logFiles, NO_ROTATION, positionCache, transactionIdStore, DATABASE_HEALTH));
CorruptedLogsTruncator logPruner = new CorruptedLogsTruncator(databaseDirectory, logFiles, fileSystem, INSTANCE);
life.add(new TransactionLogsRecovery(new TestRecoveryService(visitor, logFiles, txStore, recoveryPerformed), logPruner, new LifecycleAdapter(), mock(RecoveryMonitor.class), ProgressReporter.SILENT, false, EMPTY_CHECKER, PageCacheTracer.NULL));
// WHEN
try {
life.start();
} finally {
life.shutdown();
}
// THEN
assertEquals(1, visitor.getVisitedTransactions());
assertTrue(recoveryPerformed.get());
}
Aggregations