Search in sources :

Example 41 with Monitors

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);
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Monitors(org.neo4j.monitoring.Monitors)

Example 42 with Monitors

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);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ThreadSafePeakMemoryTracker(org.neo4j.memory.ThreadSafePeakMemoryTracker) Monitors(org.neo4j.monitoring.Monitors) GBPTree(org.neo4j.index.internal.gbptree.GBPTree) ByteBufferFactory(org.neo4j.io.memory.ByteBufferFactory) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 43 with Monitors

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);
}
Also used : IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) Monitors(org.neo4j.monitoring.Monitors) ExtensionCallback(org.neo4j.test.extension.ExtensionCallback)

Example 44 with 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());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Monitors(org.neo4j.monitoring.Monitors) Test(org.junit.jupiter.api.Test)

Example 45 with Monitors

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);
}
Also used : RelationshipModifications(org.neo4j.storageengine.api.txstate.RelationshipModifications) BeforeEach(org.junit.jupiter.api.BeforeEach) Record.isNull(org.neo4j.kernel.impl.store.record.Record.isNull) RepeatedTest(org.junit.jupiter.api.RepeatedTest) MutableInt(org.apache.commons.lang3.mutable.MutableInt) ArrayUtil.indexOf(org.neo4j.internal.helpers.ArrayUtil.indexOf) LongSupplier(java.util.function.LongSupplier) RandomExtension(org.neo4j.test.extension.RandomExtension) OUTGOING(org.neo4j.storageengine.api.RelationshipDirection.OUTGOING) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Config(org.neo4j.configuration.Config) LockType(org.neo4j.lock.LockType) GroupDegreeCommand.combinedKeyOnGroupAndDirection(org.neo4j.internal.recordstorage.Command.GroupDegreeCommand.combinedKeyOnGroupAndDirection) NullLogProvider(org.neo4j.logging.NullLogProvider) IdSequence(org.neo4j.internal.id.IdSequence) Collections.singletonList(java.util.Collections.singletonList) NO_LABELS_FIELD(org.neo4j.kernel.impl.store.record.Record.NO_LABELS_FIELD) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Monitors(org.neo4j.monitoring.Monitors) RandomRule(org.neo4j.test.rule.RandomRule) MutableLong(org.apache.commons.lang3.mutable.MutableLong) Map(java.util.Map) RelationshipData(org.neo4j.internal.recordstorage.FlatRelationshipModifications.RelationshipData) FlatRelationshipModifications.relationship(org.neo4j.internal.recordstorage.FlatRelationshipModifications.relationship) EXCLUSIVE(org.neo4j.lock.LockType.EXCLUSIVE) Exceptions(org.neo4j.internal.helpers.Exceptions) RELATIONSHIP_GROUP(org.neo4j.lock.ResourceTypes.RELATIONSHIP_GROUP) Record(org.neo4j.kernel.impl.store.record.Record) RelationshipGroupDegreesStore(org.neo4j.internal.counts.RelationshipGroupDegreesStore) FlatRelationshipModifications.creations(org.neo4j.internal.recordstorage.FlatRelationshipModifications.creations) LOOP(org.neo4j.storageengine.api.RelationshipDirection.LOOP) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) FlatRelationshipModifications.modifications(org.neo4j.internal.recordstorage.FlatRelationshipModifications.modifications) RELATIONSHIP_DELETE(org.neo4j.lock.ResourceTypes.RELATIONSHIP_DELETE) Test(org.junit.jupiter.api.Test) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) FlatRelationshipModifications.relationships(org.neo4j.internal.recordstorage.FlatRelationshipModifications.relationships) NODE(org.neo4j.lock.ResourceTypes.NODE) EMPTY_LONG_ARRAY(org.apache.commons.lang3.ArrayUtils.EMPTY_LONG_ARRAY) Mockito.mock(org.mockito.Mockito.mock) FlatRelationshipModifications.singleCreate(org.neo4j.internal.recordstorage.FlatRelationshipModifications.singleCreate) HashMap(java.util.HashMap) MutableLongObjectMap(org.eclipse.collections.api.map.primitive.MutableLongObjectMap) EmptyMemoryTracker(org.neo4j.memory.EmptyMemoryTracker) Supplier(java.util.function.Supplier) ResourceType(org.neo4j.lock.ResourceType) RelationshipDirection(org.neo4j.storageengine.api.RelationshipDirection) ArrayList(java.util.ArrayList) Iterables.asSet(org.neo4j.internal.helpers.collection.Iterables.asSet) LongObjectMaps(org.eclipse.collections.impl.factory.primitive.LongObjectMaps) HashSet(java.util.HashSet) Inject(org.neo4j.test.extension.Inject) RelationshipChainVisitor.relationshipCollector(org.neo4j.internal.recordstorage.RelationshipChainVisitor.relationshipCollector) IntSupplier(java.util.function.IntSupplier) INCOMING(org.neo4j.storageengine.api.RelationshipDirection.INCOMING) Integer.min(java.lang.Integer.min) RELATIONSHIP(org.neo4j.lock.ResourceTypes.RELATIONSHIP) NONE(org.neo4j.lock.LockTracer.NONE) ReadableTransactionState(org.neo4j.storageengine.api.txstate.ReadableTransactionState) FlatRelationshipModifications.deletions(org.neo4j.internal.recordstorage.FlatRelationshipModifications.deletions) IGNORE(org.neo4j.lock.ResourceLocker.IGNORE) ResourceLocker(org.neo4j.lock.ResourceLocker) FlatRelationshipModifications.singleDelete(org.neo4j.internal.recordstorage.FlatRelationshipModifications.singleDelete) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) NULL_MONITOR(org.neo4j.internal.recordstorage.RecordAccess.LoadMonitor.NULL_MONITOR) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Monitors(org.neo4j.monitoring.Monitors) ReadableTransactionState(org.neo4j.storageengine.api.txstate.ReadableTransactionState) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Monitors (org.neo4j.monitoring.Monitors)45 Test (org.junit.jupiter.api.Test)13 Path (java.nio.file.Path)7 Config (org.neo4j.configuration.Config)7 RecoveryCleanupWorkCollector (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)7 Dependencies (org.neo4j.collection.Dependencies)6 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)5 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)5 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)5 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)5 BoltKernelDatabaseManagementServiceProvider (org.neo4j.bolt.dbapi.impl.BoltKernelDatabaseManagementServiceProvider)4 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)4 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)4 Log (org.neo4j.logging.Log)4 MemoryTracker (org.neo4j.memory.MemoryTracker)4 IOException (java.io.IOException)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)3