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