Search in sources :

Example 1 with CountsTracker

use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.

the class HaCountsIT method assertOnIndexCounts.

private void assertOnIndexCounts(int expectedIndexUpdates, int expectedIndexSize, int expectedUniqueValues, int expectedSampleSize, long indexId, HighlyAvailableGraphDatabase db) {
    CountsTracker counts = counts(db);
    assertDoubleLongEquals(expectedIndexUpdates, expectedIndexSize, counts.indexUpdatesAndSize(indexId, newDoubleLongRegister()));
    assertDoubleLongEquals(expectedUniqueValues, expectedSampleSize, counts.indexSample(indexId, newDoubleLongRegister()));
}
Also used : CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker)

Example 2 with CountsTracker

use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.

the class FullCheck method execute.

ConsistencySummaryStatistics execute(DirectStoreAccess stores, Log log, Monitor reportMonitor) throws ConsistencyCheckIncompleteException {
    ConsistencySummaryStatistics summary = new ConsistencySummaryStatistics();
    InconsistencyReport report = new InconsistencyReport(new InconsistencyMessageLogger(log), summary);
    OwnerCheck ownerCheck = new OwnerCheck(checkPropertyOwners);
    CountsBuilderDecorator countsBuilder = new CountsBuilderDecorator(stores.nativeStores());
    CheckDecorator decorator = new CheckDecorator.ChainCheckDecorator(ownerCheck, countsBuilder);
    CacheAccess cacheAccess = new DefaultCacheAccess(statistics.getCounts(), threads);
    RecordAccess records = recordAccess(stores.nativeStores(), cacheAccess);
    execute(stores, decorator, records, report, cacheAccess, reportMonitor);
    ownerCheck.scanForOrphanChains(progressFactory);
    if (checkGraph) {
        CountsAccessor countsAccessor = stores.nativeStores().getCounts();
        if (countsAccessor instanceof CountsTracker) {
            CountsTracker tracker = (CountsTracker) countsAccessor;
            try {
                tracker.start();
            } catch (Exception e) {
            // let's hope it was already started :)
            }
        }
        countsBuilder.checkCounts(countsAccessor, new ConsistencyReporter(records, report), progressFactory);
    }
    if (!summary.isConsistent()) {
        log.warn("Inconsistencies found: " + summary);
    }
    return summary;
}
Also used : DirectRecordAccess(org.neo4j.consistency.store.DirectRecordAccess) CacheSmallStoresRecordAccess(org.neo4j.consistency.store.CacheSmallStoresRecordAccess) RecordAccess(org.neo4j.consistency.store.RecordAccess) InconsistencyReport(org.neo4j.consistency.report.InconsistencyReport) ConsistencyReporter(org.neo4j.consistency.report.ConsistencyReporter) CacheAccess(org.neo4j.consistency.checking.cache.CacheAccess) DefaultCacheAccess(org.neo4j.consistency.checking.cache.DefaultCacheAccess) CountsAccessor(org.neo4j.kernel.impl.api.CountsAccessor) DefaultCacheAccess(org.neo4j.consistency.checking.cache.DefaultCacheAccess) CheckDecorator(org.neo4j.consistency.checking.CheckDecorator) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) InconsistencyMessageLogger(org.neo4j.consistency.report.InconsistencyMessageLogger) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics)

Example 3 with CountsTracker

use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.

the class CountsStoreTransactionApplierTest method shouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar.

@Test
public void shouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar() throws Exception {
    // GIVEN
    final CountsTracker tracker = mock(CountsTracker.class);
    final CountsAccessor.Updater updater = mock(CountsAccessor.Updater.class);
    when(tracker.apply(anyLong())).thenReturn(Optional.of(updater));
    final CountsStoreBatchTransactionApplier applier = new CountsStoreBatchTransactionApplier(tracker, TransactionApplicationMode.INTERNAL);
    // WHEN
    try (TransactionApplier txApplier = applier.startTx(new TransactionToApply(null, 2L))) {
        txApplier.visitNodeCountsCommand(new Command.NodeCountsCommand(ReadOperations.ANY_LABEL, 1));
    }
    // THEN
    verify(updater, times(1)).incrementNodeCount(ReadOperations.ANY_LABEL, 1);
}
Also used : Command(org.neo4j.kernel.impl.transaction.command.Command) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) Test(org.junit.Test)

Example 4 with CountsTracker

use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.

the class CountsComputer method recomputeCounts.

public static void recomputeCounts(NeoStores stores) {
    MetaDataStore metaDataStore = stores.getMetaDataStore();
    CountsTracker counts = stores.getCounts();
    try (CountsAccessor.Updater updater = counts.reset(metaDataStore.getLastCommittedTransactionId())) {
        new CountsComputer(stores).initialize(updater);
    }
}
Also used : CountsAccessor(org.neo4j.kernel.impl.api.CountsAccessor) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker)

Example 5 with CountsTracker

use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.

the class StoreMigrator method rebuildCountsFromScratch.

private void rebuildCountsFromScratch(File storeDir, long lastTxId, PageCache pageCache) {
    final File storeFileBase = new File(storeDir, MetaDataStore.DEFAULT_NAME + StoreFactory.COUNTS_STORE);
    StoreFactory storeFactory = new StoreFactory(storeDir, pageCache, fileSystem, NullLogProvider.getInstance());
    try (NeoStores neoStores = storeFactory.openAllNeoStores()) {
        NodeStore nodeStore = neoStores.getNodeStore();
        RelationshipStore relationshipStore = neoStores.getRelationshipStore();
        try (Lifespan life = new Lifespan()) {
            int highLabelId = (int) neoStores.getLabelTokenStore().getHighId();
            int highRelationshipTypeId = (int) neoStores.getRelationshipTypeTokenStore().getHighId();
            CountsComputer initializer = new CountsComputer(lastTxId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId);
            life.add(new CountsTracker(logService.getInternalLogProvider(), fileSystem, pageCache, config, storeFileBase).setInitializer(initializer));
        }
    }
}
Also used : NodeStore(org.neo4j.kernel.impl.store.NodeStore) CountsComputer(org.neo4j.kernel.impl.store.CountsComputer) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) PagedFile(org.neo4j.io.pagecache.PagedFile) StoreFile(org.neo4j.kernel.impl.storemigration.StoreFile) File(java.io.File) Lifespan(org.neo4j.kernel.lifecycle.Lifespan)

Aggregations

CountsTracker (org.neo4j.kernel.impl.store.counts.CountsTracker)15 Test (org.junit.Test)6 IOException (java.io.IOException)4 CountsAccessor (org.neo4j.kernel.impl.api.CountsAccessor)4 Transaction (org.neo4j.graphdb.Transaction)3 File (java.io.File)2 Node (org.neo4j.graphdb.Node)2 PagedFile (org.neo4j.io.pagecache.PagedFile)2 HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)2 ManagedCluster (org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster)2 NeoStores (org.neo4j.kernel.impl.store.NeoStores)2 NodeStore (org.neo4j.kernel.impl.store.NodeStore)2 UnderlyingStorageException (org.neo4j.kernel.impl.store.UnderlyingStorageException)2 ReadOnlyCountsTracker (org.neo4j.kernel.impl.store.counts.ReadOnlyCountsTracker)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)2 CheckDecorator (org.neo4j.consistency.checking.CheckDecorator)1 CacheAccess (org.neo4j.consistency.checking.cache.CacheAccess)1 DefaultCacheAccess (org.neo4j.consistency.checking.cache.DefaultCacheAccess)1 ConsistencyReporter (org.neo4j.consistency.report.ConsistencyReporter)1