Search in sources :

Example 16 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class ConfigTest method shouldRetainCustomConfigOutsideNamespaceAndPassOnBufferedLogInWithMethods.

@Test
public void shouldRetainCustomConfigOutsideNamespaceAndPassOnBufferedLogInWithMethods() throws Exception {
    // Given
    Log log = mock(Log.class);
    Config first = Config.embeddedDefaults(stringMap("first.jibberish", "bah"));
    // When
    first.setLogger(log);
    Config second = first.withDefaults(stringMap("second.jibberish", "baah"));
    Config third = second.with(stringMap("third.jibberish", "baaah"));
    // Then
    verifyNoMoreInteractions(log);
    assertEquals(Optional.of("bah"), third.getRaw("first.jibberish"));
    assertEquals(Optional.of("baah"), third.getRaw("second.jibberish"));
    assertEquals(Optional.of("baaah"), third.getRaw("third.jibberish"));
}
Also used : Log(org.neo4j.logging.Log) LoadableConfig(org.neo4j.configuration.LoadableConfig) Test(org.junit.Test)

Example 17 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class ConfigTest method shouldWarnAndDiscardUnknownOptionsInReservedNamespaceAndPassOnBufferedLogInWithMethods.

@Test
public void shouldWarnAndDiscardUnknownOptionsInReservedNamespaceAndPassOnBufferedLogInWithMethods() throws Exception {
    // Given
    Log log = mock(Log.class);
    File confFile = testDirectory.file("test.conf");
    assertTrue(confFile.createNewFile());
    Config first = Config.embeddedDefaults(Optional.of(confFile), stringMap(GraphDatabaseSettings.strict_config_validation.name(), "false", "ha.jibberish", "baah", "dbms.jibberish", "booh"));
    // When
    first.setLogger(log);
    first.with(stringMap("causal_clustering.jibberish", "baah"));
    // Then
    verify(log).warn("Unknown config option: %s", "dbms.jibberish");
    verify(log).warn("Unknown config option: %s", "ha.jibberish");
    verifyNoMoreInteractions(log);
}
Also used : Log(org.neo4j.logging.Log) LoadableConfig(org.neo4j.configuration.LoadableConfig) File(java.io.File) Test(org.junit.Test)

Example 18 with Log

use of org.neo4j.logging.Log 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 19 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class NativeLabelScanStoreExtension method newInstance.

@Override
public Lifecycle newInstance(KernelContext context, Dependencies dependencies) throws Throwable {
    Log log = dependencies.getLogService().getInternalLog(NativeLabelScanStore.class);
    Monitor monitor = new LoggingMonitor(log, this.monitor);
    NativeLabelScanStore labelScanStore = new NativeLabelScanStore(dependencies.pageCache(), context.storeDir(), new FullLabelStream(dependencies.indexStoreView()), dependencies.getConfig().get(GraphDatabaseSettings.read_only), monitor);
    return new LabelScanStoreProvider(NAME, labelScanStore);
}
Also used : LoggingMonitor(org.neo4j.kernel.api.labelscan.LoggingMonitor) Monitor(org.neo4j.kernel.api.labelscan.LabelScanStore.Monitor) NativeLabelScanStore(org.neo4j.kernel.impl.index.labelscan.NativeLabelScanStore) Log(org.neo4j.logging.Log) LoggingMonitor(org.neo4j.kernel.api.labelscan.LoggingMonitor)

Example 20 with Log

use of org.neo4j.logging.Log in project neo4j by neo4j.

the class EditionModule method createFileSystemWatcherService.

protected FileSystemWatcherService createFileSystemWatcherService(FileSystemAbstraction fileSystem, File storeDir, LogService logging, JobScheduler jobScheduler, Predicate<String> fileNameFilter) {
    try {
        RestartableFileSystemWatcher watcher = new RestartableFileSystemWatcher(fileSystem.fileWatcher());
        watcher.addFileWatchEventListener(new DefaultFileDeletionEventListener(logging, fileNameFilter));
        watcher.watch(storeDir);
        // register to watch store dir parent folder to see when store dir removed
        watcher.watch(storeDir.getParentFile());
        return new DefaultFileSystemWatcherService(jobScheduler, watcher);
    } catch (Exception e) {
        Log log = logging.getInternalLog(getClass());
        log.warn("Can not create file watcher for current file system. File monitoring capabilities for store " + "files will be disabled.", e);
        return FileSystemWatcherService.EMPTY_WATCHER;
    }
}
Also used : DefaultFileDeletionEventListener(org.neo4j.kernel.impl.util.watcher.DefaultFileDeletionEventListener) Log(org.neo4j.logging.Log) DefaultFileSystemWatcherService(org.neo4j.kernel.impl.util.watcher.DefaultFileSystemWatcherService) RestartableFileSystemWatcher(org.neo4j.io.fs.watcher.RestartableFileSystemWatcher) KernelException(org.neo4j.kernel.api.exceptions.KernelException)

Aggregations

Log (org.neo4j.logging.Log)91 Test (org.junit.Test)63 NullLog (org.neo4j.logging.NullLog)29 File (java.io.File)12 LogProvider (org.neo4j.logging.LogProvider)12 IOException (java.io.IOException)9 Config (org.neo4j.kernel.configuration.Config)9 BasicContext (org.neo4j.kernel.api.proc.BasicContext)8 Map (java.util.Map)7 NullLogProvider (org.neo4j.logging.NullLogProvider)7 PageCache (org.neo4j.io.pagecache.PageCache)6 CallableProcedure (org.neo4j.kernel.api.proc.CallableProcedure)6 LogService (org.neo4j.kernel.impl.logging.LogService)6 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 Monitors (org.neo4j.kernel.monitoring.Monitors)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 Before (org.junit.Before)4 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)4 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)4