use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class CancelIndexPopulationIT method shouldKeepIndexInPopulatingStateBetweenRestarts.
@Test
void shouldKeepIndexInPopulatingStateBetweenRestarts() throws InterruptedException {
DatabaseManagementService dbms = new TestDatabaseManagementServiceBuilder(directory.homePath()).build();
try {
GraphDatabaseAPI db = (GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME);
// given
Monitors monitors = db.getDependencyResolver().resolveDependency(Monitors.class);
Barrier.Control barrier = new Barrier.Control();
monitors.addMonitorListener(populationCompletionBlocker(barrier));
// when
createRelevantNode(db);
createIndex(db);
barrier.await();
} finally {
// This call to shutdown will eventually make a call to populationCancelled on the monitor below
dbms.shutdown();
}
dbms = new TestDatabaseManagementServiceBuilder(directory.homePath()).build();
try {
GraphDatabaseAPI db = (GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME);
// then
assertEquals(Schema.IndexState.ONLINE, awaitAndGetIndexState(db));
} finally {
dbms.shutdown();
}
}
use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class RecoveryIT method shouldForceRecoveryEvenThoughNotSeeminglyRequired.
@Test
void shouldForceRecoveryEvenThoughNotSeeminglyRequired() throws Exception {
// given
GraphDatabaseAPI db = createDatabase();
generateSomeData(db);
DatabaseLayout layout = db.databaseLayout();
managementService.shutdown();
assertFalse(isRecoveryRequired(layout));
// Make an ID generator, say for the node store, dirty
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystem, immediate(), "my db");
try (IdGenerator idGenerator = idGeneratorFactory.open(pageCache, layout.idNodeStore(), IdType.NODE, () -> 0L, /*will not be used*/
10_000, writable(), Config.defaults(), NULL, Sets.immutable.empty())) {
// Merely opening a marker will make the backing GBPTree dirty
idGenerator.marker(NULL).close();
}
assertFalse(isRecoveryRequired(layout));
assertTrue(idGeneratorIsDirty(layout.idNodeStore(), IdType.NODE));
// when
MutableBoolean recoveryRunEvenThoughNoCommitsAfterLastCheckpoint = new MutableBoolean();
RecoveryStartInformationProvider.Monitor monitor = new RecoveryStartInformationProvider.Monitor() {
@Override
public void noCommitsAfterLastCheckPoint(LogPosition logPosition) {
recoveryRunEvenThoughNoCommitsAfterLastCheckpoint.setTrue();
}
};
Monitors monitors = new Monitors();
monitors.addMonitorListener(monitor);
Recovery.performRecovery(fileSystem, pageCache, EMPTY, Config.defaults(), layout, defaultStorageEngine(), true, nullLogProvider(), monitors, Iterables.cast(Services.loadAll(ExtensionFactory.class)), Optional.empty(), null, INSTANCE, Clock.systemUTC());
// then
assertFalse(idGeneratorIsDirty(layout.idNodeStore(), IdType.NODE));
assertTrue(recoveryRunEvenThoughNoCommitsAfterLastCheckpoint.booleanValue());
}
use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class RecoveryCleanupIT method setMonitor.
private void setMonitor(Object monitor) {
Monitors monitors = new Monitors();
monitors.addMonitorListener(monitor);
factory.setMonitors(monitors);
}
use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class TransactionStateMachineSPIProviderV4Test method newSpiProvider.
private TransactionStateMachineSPIProvider newSpiProvider(DatabaseManagementService managementService) {
var clock = mock(SystemNanoClock.class);
var dbProvider = new BoltKernelDatabaseManagementServiceProvider(managementService, new Monitors(), clock, Duration.ZERO);
return new TransactionStateMachineSPIProviderV4(dbProvider, mockBoltChannel, clock, mock(MemoryTracker.class, RETURNS_MOCKS));
}
use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class TransactionStateMachineSPIProviderV4Test method shouldAllocateMemoryForTransactionStateMachineSPI.
@Test
void shouldAllocateMemoryForTransactionStateMachineSPI() throws BoltProtocolBreachFatality, BoltIOException {
String databaseName = "neo4j";
var clock = mock(SystemNanoClock.class);
DatabaseManagementService managementService = managementService(databaseName);
var memoryTracker = mock(MemoryTracker.class);
var scopedMemoryTracker = mock(MemoryTracker.class, RETURNS_MOCKS);
when(mockBoltChannel.defaultDatabase()).thenReturn("neo4j");
when(memoryTracker.getScopedMemoryTracker()).thenReturn(scopedMemoryTracker);
var dbProvider = new BoltKernelDatabaseManagementServiceProvider(managementService, new Monitors(), clock, Duration.ZERO);
var spiProvider = new TransactionStateMachineSPIProviderV4(dbProvider, mockBoltChannel, clock, memoryTracker);
spiProvider.getTransactionStateMachineSPI("", mock(StatementProcessorReleaseManager.class));
verify(memoryTracker).getScopedMemoryTracker();
verify(scopedMemoryTracker).allocateHeap(TransactionStateMachineV4SPI.SHALLOW_SIZE);
verify(scopedMemoryTracker).allocateHeap(BoltKernelGraphDatabaseServiceProvider.SHALLOW_SIZE);
verify(scopedMemoryTracker).getScopedMemoryTracker();
verifyNoMoreInteractions(memoryTracker);
verifyNoMoreInteractions(scopedMemoryTracker);
}
Aggregations