use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class ShortestPath method resolveMonitor.
private void resolveMonitor(Node node) {
if (dataMonitor == null) {
GraphDatabaseService service = context.databaseService();
Monitors monitors = ((GraphDatabaseFacade) service).getDependencyResolver().resolveDependency(Monitors.class);
dataMonitor = monitors.newMonitor(DataMonitor.class);
}
}
use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class BlockBasedIndexPopulatorTest method shouldFlushTreeOnScanCompleted.
@Test
void shouldFlushTreeOnScanCompleted() throws IndexEntryConflictException, IOException {
// given
ThreadSafePeakMemoryTracker memoryTracker = new ThreadSafePeakMemoryTracker();
ByteBufferFactory bufferFactory = new ByteBufferFactory(UnsafeDirectByteBufferAllocator::new, 100);
AtomicInteger checkpoints = new AtomicInteger();
GBPTree.Monitor treeMonitor = new GBPTree.Monitor.Adaptor() {
@Override
public void checkpointCompleted() {
checkpoints.incrementAndGet();
}
};
Monitors monitors = new Monitors(databaseIndexContext.monitors, NullLogProvider.getInstance());
monitors.addMonitorListener(treeMonitor);
databaseIndexContext = DatabaseIndexContext.builder(databaseIndexContext).withMonitors(monitors).build();
BlockBasedIndexPopulator<GenericKey, NativeIndexValue> populator = instantiatePopulator(NO_MONITOR, bufferFactory, memoryTracker);
try {
// when
int numberOfCheckPointsBeforeScanCompleted = checkpoints.get();
populator.scanCompleted(nullInstance, populationWorkScheduler, NULL);
// then
assertEquals(numberOfCheckPointsBeforeScanCompleted + 1, checkpoints.get());
} finally {
populator.close(true, NULL);
}
}
use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class SchemaAcceptanceTest method configure.
@ExtensionCallback
void configure(TestDatabaseManagementServiceBuilder builder) {
Monitors monitors = new Monitors();
IndexingService.MonitorAdapter trappingMonitor = new IndexingService.MonitorAdapter() {
@Override
public void indexPopulationScanComplete() {
if (trapPopulation.get()) {
populationScanFinished.reached();
}
}
};
monitors.addMonitorListener(trappingMonitor);
builder.setMonitors(monitors);
}
use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class TokenIndexPopulatorTest method shouldNotRelayMonitorCallsToRegisteredGBPTreeMonitorWithDifferentTag.
@Test
void shouldNotRelayMonitorCallsToRegisteredGBPTreeMonitorWithDifferentTag() throws IOException {
// Given
AtomicBoolean checkpointCompletedCall = new AtomicBoolean();
Monitors monitors = new Monitors();
monitors.addMonitorListener(getCheckpointCompletedListener(checkpointCompletedCall), "differentTag");
populator = createPopulator(pageCache, monitors, "tag");
// When
populator.create();
populator.close(true, NULL);
// Then
assertFalse(checkpointCompletedCall.get());
}
use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.
the class RelationshipModifierTest method setUp.
@BeforeEach
void setUp() {
RelationshipGroupGetter relationshipGroupGetter = new RelationshipGroupGetter(idSequence(), CursorContext.NULL);
PropertyDeleter propertyDeleter = new PropertyDeleter(new PropertyTraverser(CursorContext.NULL), null, null, NullLogProvider.nullLogProvider(), Config.defaults(), CursorContext.NULL, EmptyMemoryTracker.INSTANCE);
modifier = new RelationshipModifier(relationshipGroupGetter, propertyDeleter, DENSE_THRESHOLD - 1, /*because the trigger happens on > */
true, CursorContext.NULL, EmptyMemoryTracker.INSTANCE);
monitors = new Monitors(null, (t, m) -> {
Exceptions.throwIfUnchecked(t);
throw new RuntimeException(t);
});
locks = new TrackingResourceLocker(random, monitors.newMonitor(TrackingResourceLocker.LockAcquisitionMonitor.class));
txState = mock(ReadableTransactionState.class);
store = new MapRecordStore();
monitors.addMonitorListener(new LockVerificationMonitor(locks, txState, store));
groupUpdater = new GroupUpdater(store);
}
Aggregations