use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class DumpCommand method execute.
@Override
public void execute() {
var databaseName = database.name();
Path archive = buildArchivePath(databaseName, to.toAbsolutePath());
var memoryTracker = EmptyMemoryTracker.INSTANCE;
Config config = CommandHelpers.buildConfig(ctx, allowCommandExpansion);
DatabaseLayout databaseLayout = Neo4jLayout.of(config).databaseLayout(databaseName);
try {
Validators.CONTAINS_EXISTING_DATABASE.validate(databaseLayout.databaseDirectory());
} catch (IllegalArgumentException e) {
throw new CommandFailedException("Database does not exist: " + databaseName, e);
}
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
if (fileSystem.fileExists(databaseLayout.file(StoreUpgrader.MIGRATION_DIRECTORY))) {
throw new CommandFailedException("Store migration folder detected - A dump can not be taken during a store migration. Make sure " + "store migration is completed before trying again.");
}
} catch (IOException e) {
wrapIOException(e);
}
try (Closeable ignored = LockChecker.checkDatabaseLock(databaseLayout)) {
checkDbState(databaseLayout, config, memoryTracker);
dump(databaseLayout, archive);
} catch (FileLockException e) {
throw new CommandFailedException("The database is in use. Stop database '" + databaseName + "' and try again.", e);
} catch (IOException e) {
wrapIOException(e);
} catch (CannotWriteException e) {
throw new CommandFailedException("You do not have permission to dump the database.", e);
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class Recovery method performRecovery.
/**
* Performs recovery of database described by provided layout.
* Transaction logs should be located in their default location.
* If recovery is not required nothing will be done to the the database or logs.
* Note: used by external tools.
* @param databaseLayout database to recover layout.
* @param tracers underlying events tracers.
* @throws IOException on any unexpected I/O exception encountered during recovery.
*/
public static void performRecovery(DatabaseLayout databaseLayout, DatabaseTracers tracers, MemoryTracker memoryTracker) throws Exception {
requireNonNull(databaseLayout);
Config config = defaults();
try (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction();
JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
PageCache pageCache = getPageCache(config, fs, jobScheduler)) {
performRecovery(fs, pageCache, tracers, config, databaseLayout, memoryTracker);
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class Recovery method isRecoveryRequired.
/**
* Check if recovery is required for a store described by provided layout.
* Custom root location for transaction logs can be provided using {@link GraphDatabaseSettings#transaction_logs_root_path} config setting value.
* @param databaseLayout layout of database to check for recovery
* @param config custom configuration
* @return true if recovery is required, false otherwise.
* @throws IOException on any unexpected I/O exception encountered during recovery.
*/
public static boolean isRecoveryRequired(DatabaseLayout databaseLayout, Config config, MemoryTracker memoryTracker) throws Exception {
requireNonNull(databaseLayout);
requireNonNull(config);
try (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction()) {
return isRecoveryRequired(fs, databaseLayout, config, memoryTracker);
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class NeoBootstrapper method setupLogging.
private static Log4jLogProvider setupLogging(Config config) {
LogConfig.Builder builder = LogConfig.createBuilder(new DefaultFileSystemAbstraction(), config.get(GraphDatabaseSettings.store_user_log_path), config.get(GraphDatabaseSettings.store_internal_log_level)).withTimezone(config.get(GraphDatabaseSettings.db_timezone)).withFormat(config.get(GraphDatabaseSettings.store_user_log_format)).withCategory(false).withRotation(config.get(GraphDatabaseSettings.store_user_log_rotation_threshold), config.get(GraphDatabaseSettings.store_user_log_max_archives));
if (config.get(GraphDatabaseSettings.store_user_log_to_stdout)) {
builder.logToSystemOut();
}
Neo4jLoggerContext ctx = builder.build();
Log4jLogProvider userLogProvider = new Log4jLogProvider(ctx);
JULBridge.resetJUL();
Logger.getLogger("").setLevel(Level.WARNING);
JULBridge.forwardTo(userLogProvider);
JettyLogBridge.setLogProvider(userLogProvider);
return userLogProvider;
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class BatchInserters method inserter.
/**
* Get a {@link BatchInserter} given a store directory.
*
* @param databaseLayout directory where particular neo4j database is located
* @return a new {@link BatchInserter}
* @throws IOException if there is an IO error
*/
public static BatchInserter inserter(DatabaseLayout databaseLayout) throws IOException {
DefaultFileSystemAbstraction fileSystem = createFileSystem();
BatchInserter batchInserter = inserter(databaseLayout, fileSystem, Config.defaults());
return new FileSystemClosingBatchInserter(batchInserter, fileSystem);
}
Aggregations