Search in sources :

Example 1 with DatabaseTracers

use of org.neo4j.kernel.database.DatabaseTracers in project neo4j by neo4j.

the class RecoveryIT method tracePageCacheAccessOnDatabaseRecovery.

@Test
void tracePageCacheAccessOnDatabaseRecovery() throws Throwable {
    GraphDatabaseService database = createDatabase();
    int numberOfNodes = 10;
    for (int i = 0; i < numberOfNodes; i++) {
        createSingleNode(database);
    }
    managementService.shutdown();
    RecoveryHelpers.removeLastCheckpointRecordFromLastLogFile(databaseLayout, fileSystem);
    var pageCacheTracer = new DefaultPageCacheTracer();
    var tracers = new DatabaseTracers(DatabaseTracer.NULL, LockTracer.NONE, pageCacheTracer);
    recoverDatabase(tracers);
    long pins = pageCacheTracer.pins();
    assertThat(pins).isGreaterThan(0);
    assertThat(pageCacheTracer.unpins()).isEqualTo(pins);
    assertThat(pageCacheTracer.hits()).isGreaterThan(0).isLessThanOrEqualTo(pins);
    assertThat(pageCacheTracer.faults()).isGreaterThan(0).isLessThanOrEqualTo(pins);
    GraphDatabaseService recoveredDatabase = createDatabase();
    try (Transaction tx = recoveredDatabase.beginTx()) {
        assertEquals(numberOfNodes, count(tx.getAllNodes()));
    } finally {
        managementService.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) DatabaseTracers(org.neo4j.kernel.database.DatabaseTracers) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 2 with DatabaseTracers

use of org.neo4j.kernel.database.DatabaseTracers in project neo4j by neo4j.

the class KernelTransactionsTest method newKernelTransactions.

private KernelTransactions newKernelTransactions(Locks locks, StorageEngine storageEngine, TransactionCommitProcess commitProcess, boolean testKernelTransactions, Config config) {
    LifeSupport life = new LifeSupport();
    life.start();
    TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
    when(transactionIdStore.getLastCommittedTransaction()).thenReturn(new TransactionId(0, 0, 0));
    Tracers tracers = new Tracers("null", NullLog.getInstance(), new Monitors(), mock(JobScheduler.class), clock, config);
    final DatabaseTracers databaseTracers = new DatabaseTracers(tracers);
    KernelTransactions transactions;
    if (testKernelTransactions) {
        transactions = createTestTransactions(storageEngine, commitProcess, transactionIdStore, databaseTracers, locks, clock, databaseAvailabilityGuard);
    } else {
        transactions = createTransactions(storageEngine, commitProcess, transactionIdStore, databaseTracers, locks, clock, databaseAvailabilityGuard, config);
    }
    transactions.start();
    return transactions;
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) DatabaseTracers(org.neo4j.kernel.database.DatabaseTracers) Monitors(org.neo4j.monitoring.Monitors) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) TransactionId(org.neo4j.storageengine.api.TransactionId) Tracers(org.neo4j.kernel.monitoring.tracing.Tracers) DatabaseTracers(org.neo4j.kernel.database.DatabaseTracers)

Aggregations

DatabaseTracers (org.neo4j.kernel.database.DatabaseTracers)2 Test (org.junit.jupiter.api.Test)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Transaction (org.neo4j.graphdb.Transaction)1 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)1 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)1 Tracers (org.neo4j.kernel.monitoring.tracing.Tracers)1 Monitors (org.neo4j.monitoring.Monitors)1 JobScheduler (org.neo4j.scheduler.JobScheduler)1 TransactionId (org.neo4j.storageengine.api.TransactionId)1 TransactionIdStore (org.neo4j.storageengine.api.TransactionIdStore)1