use of org.neo4j.kernel.impl.logging.StoreLogService in project neo4j by neo4j.
the class StoreMigration method run.
public void run(final FileSystemAbstraction fs, final File storeDirectory, Config config, LogProvider userLogProvider) throws IOException {
StoreLogService logService = StoreLogService.withUserLogProvider(userLogProvider).inLogsDirectory(fs, storeDirectory);
VisibleMigrationProgressMonitor progressMonitor = new VisibleMigrationProgressMonitor(logService.getUserLog(StoreMigration.class));
LifeSupport life = new LifeSupport();
life.add(logService);
// Add participants from kernel extensions...
LegacyIndexProvider legacyIndexProvider = new LegacyIndexProvider();
Log log = userLogProvider.getLog(StoreMigration.class);
try (PageCache pageCache = createPageCache(fs, config)) {
Dependencies deps = new Dependencies();
deps.satisfyDependencies(fs, config, legacyIndexProvider, pageCache, logService);
KernelContext kernelContext = new SimpleKernelContext(storeDirectory, DatabaseInfo.UNKNOWN, deps);
KernelExtensions kernelExtensions = life.add(new KernelExtensions(kernelContext, GraphDatabaseDependencies.newDependencies().kernelExtensions(), deps, ignore()));
// Add the kernel store migrator
life.start();
SchemaIndexProvider schemaIndexProvider = kernelExtensions.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance());
LabelScanStoreProvider labelScanStoreProvider = kernelExtensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config));
long startTime = System.currentTimeMillis();
DatabaseMigrator migrator = new DatabaseMigrator(progressMonitor, fs, config, logService, schemaIndexProvider, labelScanStoreProvider, legacyIndexProvider.getIndexProviders(), pageCache, RecordFormatSelector.selectForConfig(config, userLogProvider));
migrator.migrate(storeDirectory);
long duration = System.currentTimeMillis() - startTime;
log.info(format("Migration completed in %d s%n", duration / 1000));
} catch (Exception e) {
throw new StoreUpgrader.UnableToUpgradeException("Failure during upgrade", e);
} finally {
life.shutdown();
}
}
use of org.neo4j.kernel.impl.logging.StoreLogService in project neo4j by neo4j.
the class PlatformModule method createLogService.
protected LogService createLogService(LogProvider userLogProvider) {
long internalLogRotationThreshold = config.get(GraphDatabaseSettings.store_internal_log_rotation_threshold);
long internalLogRotationDelay = config.get(GraphDatabaseSettings.store_internal_log_rotation_delay);
int internalLogMaxArchives = config.get(GraphDatabaseSettings.store_internal_log_max_archives);
final StoreLogService.Builder builder = StoreLogService.withRotation(internalLogRotationThreshold, internalLogRotationDelay, internalLogMaxArchives, jobScheduler);
if (userLogProvider != null) {
builder.withUserLogProvider(userLogProvider);
}
builder.withRotationListener(logProvider -> diagnosticsManager.dumpAll(logProvider.getLog(DiagnosticsManager.class)));
for (String debugContext : config.get(GraphDatabaseSettings.store_internal_debug_contexts)) {
builder.withLevel(debugContext, Level.DEBUG);
}
builder.withDefaultLevel(config.get(GraphDatabaseSettings.store_internal_log_level));
File logsDir = config.get(GraphDatabaseSettings.logs_directory);
StoreLogService logService;
try {
logService = builder.inLogsDirectory(fileSystem, logsDir);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return life.add(logService);
}
Aggregations