Search in sources :

Example 21 with TransactionIdStore

use of org.neo4j.storageengine.api.TransactionIdStore 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());
}
Also used : TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) CorruptedLogsTruncator(org.neo4j.kernel.recovery.CorruptedLogsTruncator) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter) TransactionLogsRecovery(org.neo4j.kernel.recovery.TransactionLogsRecovery) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) Test(org.junit.jupiter.api.Test)

Example 22 with TransactionIdStore

use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.

the class BoltV3TransportIT method getLastClosedTransactionId.

private long getLastClosedTransactionId() {
    DependencyResolver resolver = ((GraphDatabaseAPI) server.graphDatabaseService()).getDependencyResolver();
    TransactionIdStore txIdStore = resolver.resolveDependency(TransactionIdStore.class);
    return txIdStore.getLastClosedTransactionId();
}
Also used : TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) DependencyResolver(org.neo4j.common.DependencyResolver)

Aggregations

TransactionIdStore (org.neo4j.storageengine.api.TransactionIdStore)22 Test (org.junit.jupiter.api.Test)12 SimpleTransactionIdStore (org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore)10 LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)6 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)5 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)4 IOException (java.io.IOException)3 TransactionAppender (org.neo4j.kernel.impl.transaction.log.TransactionAppender)3 Path (java.nio.file.Path)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 BookmarkWithPrefix (org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix)2 DependencyResolver (org.neo4j.common.DependencyResolver)2 CursorContext (org.neo4j.io.pagecache.context.CursorContext)2 TransactionToApply (org.neo4j.kernel.impl.api.TransactionToApply)2 TestableTransactionAppender (org.neo4j.kernel.impl.transaction.log.TestableTransactionAppender)2 StorageEngine (org.neo4j.storageengine.api.StorageEngine)2 TransactionId (org.neo4j.storageengine.api.TransactionId)2