Search in sources :

Example 6 with SimpleLogService

use of org.neo4j.kernel.impl.logging.SimpleLogService 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)

Example 7 with SimpleLogService

use of org.neo4j.kernel.impl.logging.SimpleLogService in project neo4j by neo4j.

the class NeoStoreDataSourceTest method logModuleSetUpError.

@Test
public void logModuleSetUpError() throws Exception {
    Config config = Config.embeddedDefaults(stringMap());
    IdGeneratorFactory idGeneratorFactory = mock(IdGeneratorFactory.class);
    Throwable openStoresError = new RuntimeException("Can't set up modules");
    doThrow(openStoresError).when(idGeneratorFactory).create(any(File.class), anyLong(), anyBoolean());
    CommunityIdTypeConfigurationProvider idTypeConfigurationProvider = new CommunityIdTypeConfigurationProvider();
    AssertableLogProvider logProvider = new AssertableLogProvider();
    SimpleLogService logService = new SimpleLogService(logProvider, logProvider);
    PageCache pageCache = pageCacheRule.getPageCache(fs.get());
    NeoStoreDataSource dataSource = dsRule.getDataSource(dir.graphDbDir(), fs.get(), idGeneratorFactory, idTypeConfigurationProvider, pageCache, config, mock(DatabaseHealth.class), logService);
    try {
        dataSource.start();
        fail("Exception expected");
    } catch (Exception e) {
        assertEquals(openStoresError, e);
    }
    logProvider.assertAtLeastOnce(inLog(NeoStoreDataSource.class).warn(equalTo("Exception occurred while setting up store modules. Attempting to close things down."), equalTo(openStoresError)));
}
Also used : DatabaseHealth(org.neo4j.kernel.internal.DatabaseHealth) CommunityIdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.CommunityIdTypeConfigurationProvider) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) Config(org.neo4j.kernel.configuration.Config) IdGeneratorFactory(org.neo4j.kernel.impl.store.id.IdGeneratorFactory) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) LifecycleException(org.neo4j.kernel.lifecycle.LifecycleException) IOException(java.io.IOException) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 8 with SimpleLogService

use of org.neo4j.kernel.impl.logging.SimpleLogService in project neo4j by neo4j.

the class BoltProtocolV1Test method messageProcessingErrorIsLogged.

@Test
public void messageProcessingErrorIsLogged() throws IOException {
    RuntimeException error = new RuntimeException("Unexpected error!");
    ByteBuf data = newThrowingByteBuf(error);
    AssertableLogProvider assertableLogProvider = new AssertableLogProvider();
    SimpleLogService logService = new SimpleLogService(NullLogProvider.getInstance(), assertableLogProvider);
    BoltProtocolV1 protocol = new BoltProtocolV1(mock(BoltWorker.class), newChannelMock(), logService);
    protocol.handle(mock(ChannelHandlerContext.class), data);
    assertableLogProvider.assertExactly(inLog(BoltProtocolV1.class).error(equalTo("Failed to handle incoming Bolt message. Connection will be closed."), equalTo(error)));
}
Also used : SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) SynchronousBoltWorker(org.neo4j.bolt.v1.runtime.SynchronousBoltWorker) BoltWorker(org.neo4j.bolt.v1.runtime.BoltWorker) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Example 9 with SimpleLogService

use of org.neo4j.kernel.impl.logging.SimpleLogService in project neo4j by neo4j.

the class BatchingNeoStoresIT method startBatchingNeoStoreWithMetricsPluginEnabled.

@Test
public void startBatchingNeoStoreWithMetricsPluginEnabled() throws Exception {
    FileSystemAbstraction fileSystem = fileSystemRule.get();
    File storeDir = testDirectory.graphDbDir();
    Config config = Config.defaults().with(MapUtil.stringMap(MetricsSettings.metricsEnabled.name(), "true"));
    AssertableLogProvider provider = new AssertableLogProvider();
    SimpleLogService logService = new SimpleLogService(provider, provider);
    try (BatchingNeoStores batchingNeoStores = BatchingNeoStores.batchingNeoStores(fileSystem, storeDir, RecordFormatSelector.defaultFormat(), Configuration.DEFAULT, logService, AdditionalInitialIds.EMPTY, config)) {
    // empty block
    }
    provider.assertNone(AssertableLogProvider.inLog(MetricsExtension.class).any());
}
Also used : FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) Config(org.neo4j.kernel.configuration.Config) File(java.io.File) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.Test)

Aggregations

SimpleLogService (org.neo4j.kernel.impl.logging.SimpleLogService)9 Test (org.junit.Test)6 Config (org.neo4j.kernel.configuration.Config)6 File (java.io.File)5 PageCache (org.neo4j.io.pagecache.PageCache)4 Dependencies (org.neo4j.kernel.impl.util.Dependencies)3 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)3 IOException (java.io.IOException)2 AccessStatistics (org.neo4j.consistency.statistics.AccessStatistics)2 AccessStatsKeepingStoreAccess (org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess)2 DefaultCounts (org.neo4j.consistency.statistics.DefaultCounts)2 VerboseStatistics (org.neo4j.consistency.statistics.VerboseStatistics)2 DirectStoreAccess (org.neo4j.kernel.api.direct.DirectStoreAccess)2 LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)2 IndexStoreView (org.neo4j.kernel.impl.api.index.IndexStoreView)2 LogService (org.neo4j.kernel.impl.logging.LogService)2 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)2 KernelContext (org.neo4j.kernel.impl.spi.KernelContext)2 SimpleKernelContext (org.neo4j.kernel.impl.spi.SimpleKernelContext)2 StoreAccess (org.neo4j.kernel.impl.store.StoreAccess)2