Search in sources :

Example 1 with Statistics

use of org.neo4j.consistency.statistics.Statistics in project neo4j by neo4j.

the class ConsistencyCheckService method runFullConsistencyCheck.

public Result runFullConsistencyCheck(final File storeDir, Config config, ProgressMonitorFactory progressFactory, final LogProvider logProvider, final FileSystemAbstraction fileSystem, final PageCache pageCache, final boolean verbose, File reportDir, CheckConsistencyConfig checkConsistencyConfig) throws ConsistencyCheckIncompleteException {
    Log log = logProvider.getLog(getClass());
    config = config.with(stringMap(GraphDatabaseSettings.read_only.name(), TRUE, GraphDatabaseSettings.label_index.name(), LabelIndex.AUTO.name()));
    StoreFactory factory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fileSystem), pageCache, fileSystem, logProvider);
    ConsistencySummaryStatistics summary;
    final File reportFile = chooseReportPath(reportDir);
    Log reportLog = new ConsistencyReportLog(Suppliers.lazySingleton(() -> {
        try {
            return new PrintWriter(createOrOpenAsOuputStream(fileSystem, reportFile, true));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }));
    // Bootstrap kernel extensions
    LifeSupport life = new LifeSupport();
    try (NeoStores neoStores = factory.openAllNeoStores()) {
        IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, neoStores);
        Dependencies dependencies = new Dependencies();
        dependencies.satisfyDependencies(config, fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
        KernelContext kernelContext = new SimpleKernelContext(storeDir, UNKNOWN, dependencies);
        KernelExtensions extensions = life.add(new KernelExtensions(kernelContext, (Iterable) load(KernelExtensionFactory.class), dependencies, ignore()));
        life.start();
        LabelScanStore labelScanStore = life.add(extensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config)).getLabelScanStore());
        SchemaIndexProvider indexes = life.add(extensions.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance()));
        int numberOfThreads = defaultConsistencyCheckThreadsNumber();
        Statistics statistics;
        StoreAccess storeAccess;
        AccessStatistics stats = new AccessStatistics();
        if (verbose) {
            statistics = new VerboseStatistics(stats, new DefaultCounts(numberOfThreads), log);
            storeAccess = new AccessStatsKeepingStoreAccess(neoStores, stats);
        } else {
            statistics = Statistics.NONE;
            storeAccess = new StoreAccess(neoStores);
        }
        storeAccess.initialize();
        DirectStoreAccess stores = new DirectStoreAccess(storeAccess, labelScanStore, indexes);
        FullCheck check = new FullCheck(progressFactory, statistics, numberOfThreads, checkConsistencyConfig);
        summary = check.execute(stores, new DuplicatingLog(log, reportLog));
    } finally {
        life.shutdown();
    }
    if (!summary.isConsistent()) {
        log.warn("See '%s' for a detailed consistency report.", reportFile.getPath());
        return Result.failure(reportFile);
    }
    return Result.success(reportFile);
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) DefaultCounts(org.neo4j.consistency.statistics.DefaultCounts) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DuplicatingLog(org.neo4j.logging.DuplicatingLog) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) Dependencies(org.neo4j.kernel.impl.util.Dependencies) NamedLabelScanStoreSelectionStrategy(org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) PrintWriter(java.io.PrintWriter) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) KernelContext(org.neo4j.kernel.impl.spi.KernelContext) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) Log(org.neo4j.logging.Log) DuplicatingLog(org.neo4j.logging.DuplicatingLog) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) IOException(java.io.IOException) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) Statistics(org.neo4j.consistency.statistics.Statistics) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) FullCheck(org.neo4j.consistency.checking.full.FullCheck) KernelExtensions(org.neo4j.kernel.extension.KernelExtensions) NeoStores(org.neo4j.kernel.impl.store.NeoStores) IndexStoreView(org.neo4j.kernel.impl.api.index.IndexStoreView) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) File(java.io.File)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 FullCheck (org.neo4j.consistency.checking.full.FullCheck)1 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 AccessStatistics (org.neo4j.consistency.statistics.AccessStatistics)1 AccessStatsKeepingStoreAccess (org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess)1 DefaultCounts (org.neo4j.consistency.statistics.DefaultCounts)1 Statistics (org.neo4j.consistency.statistics.Statistics)1 VerboseStatistics (org.neo4j.consistency.statistics.VerboseStatistics)1 DirectStoreAccess (org.neo4j.kernel.api.direct.DirectStoreAccess)1 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)1 LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)1 KernelExtensionFactory (org.neo4j.kernel.extension.KernelExtensionFactory)1 KernelExtensions (org.neo4j.kernel.extension.KernelExtensions)1 NamedLabelScanStoreSelectionStrategy (org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy)1 IndexStoreView (org.neo4j.kernel.impl.api.index.IndexStoreView)1 SimpleLogService (org.neo4j.kernel.impl.logging.SimpleLogService)1 KernelContext (org.neo4j.kernel.impl.spi.KernelContext)1 SimpleKernelContext (org.neo4j.kernel.impl.spi.SimpleKernelContext)1