use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class DatabaseFileListingTest method createIndexDbFile.
private void createIndexDbFile() throws IOException {
DatabaseLayout databaseLayout = db.databaseLayout();
final Path indexFile = databaseLayout.file("index.db");
if (Files.notExists(indexFile)) {
Files.createFile(indexFile);
}
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class IdGeneratorMigrator method createEmptyPlaceHolderStoreFiles.
private Set<Path> createEmptyPlaceHolderStoreFiles(DatabaseLayout layout, RecordFormats format) {
Set<Path> createdStores = new HashSet<>();
StoreType[] storesToCreate = Stream.of(StoreType.values()).filter(t -> {
Path file = layout.file(t.getDatabaseFile());
boolean exists = fileSystem.fileExists(file);
if (!exists) {
createdStores.add(file);
}
return !exists;
}).toArray(StoreType[]::new);
createStoreFactory(layout, format, new ScanOnOpenReadOnlyIdGeneratorFactory()).openNeoStores(true, storesToCreate).close();
return createdStores;
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class LoaderTest method shouldGiveAClearErrorMessageIfTheTxLogsParentDirectoryDoesntExist.
@Test
void shouldGiveAClearErrorMessageIfTheTxLogsParentDirectoryDoesntExist() throws IOException {
Path archive = testDirectory.file("the-archive.dump");
Path txLogsDestination = Paths.get(testDirectory.absolutePath().toString(), "subdir", "txLogs");
Config config = Config.newBuilder().set(neo4j_home, testDirectory.homePath()).set(transaction_logs_root_path, txLogsDestination.toAbsolutePath()).set(default_database, "destination").build();
DatabaseLayout databaseLayout = DatabaseLayout.of(config);
fileSystem.deleteRecursively(txLogsDestination);
NoSuchFileException noSuchFileException = assertThrows(NoSuchFileException.class, () -> new Loader().load(archive, databaseLayout));
assertEquals(txLogsDestination.toString(), noSuchFileException.getMessage());
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class LoaderTest method shouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryIsNotWritable.
@Test
@DisabledOnOs(OS.WINDOWS)
@DisabledForRoot
void shouldGiveAClearErrorMessageIfTheDestinationsParentDirectoryIsNotWritable() throws IOException {
Path archive = testDirectory.file("the-archive.dump");
Path destination = testDirectory.directory("subdir/the-destination");
DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(destination);
Path parentPath = databaseLayout.databaseDirectory().getParent();
try (Closeable ignored = withPermissions(parentPath, emptySet())) {
AccessDeniedException exception = assertThrows(AccessDeniedException.class, () -> new Loader().load(archive, databaseLayout));
assertEquals(parentPath.toString(), exception.getMessage());
}
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class ArchiveTest method shouldExcludeWholeDirectoriesMatchedByTheExclusionPredicate.
@ParameterizedTest
@EnumSource(CompressionFormat.class)
void shouldExcludeWholeDirectoriesMatchedByTheExclusionPredicate(CompressionFormat compressionFormat) throws IOException, IncorrectFormat {
Path directory = testDirectory.directory("a-directory");
Path subdir = directory.resolve("subdir");
Files.createDirectories(subdir);
Files.write(subdir.resolve("a-file"), new byte[0]);
Path archive = testDirectory.file("the-archive.dump");
new Dumper().dump(directory, directory, archive, compressionFormat, path -> path.getFileName().toString().equals("subdir"));
Path txLogsRoot = testDirectory.directory("txLogsRoot");
DatabaseLayout databaseLayout = layoutWithCustomTxRoot(txLogsRoot, "the-new-directory");
new Loader().load(archive, databaseLayout);
Path expectedOutput = testDirectory.directory("expected-output");
Files.createDirectories(expectedOutput);
assertEquals(describeRecursively(expectedOutput), describeRecursively(databaseLayout.databaseDirectory()));
}
Aggregations