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"));
}
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);
}
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);
}
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);
}
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;
}
}
Aggregations