use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class HighAvailabilityBeanTest method setup.
@Before
public void setup() throws NotCompliantMBeanException {
fileSystem = new DefaultFileSystemAbstraction();
kernelData = new TestHighlyAvailableKernelData();
data = new ManagementData(bean, kernelData, ManagementSupport.load());
when(db.getDependencyResolver()).thenReturn(dependencies);
haBean = (HighAvailability) new HighAvailabilityBean().createMBean(data);
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class BatchInserters method inserter.
public static BatchInserter inserter(File storeDir, Map<String, String> config, Iterable<KernelExtensionFactory<?>> kernelExtensions) throws IOException {
DefaultFileSystemAbstraction fileSystem = createFileSystem();
BatchInserterImpl inserter = new BatchInserterImpl(storeDir, fileSystem, config, kernelExtensions);
return new FileSystemClosingBatchInserter(inserter, inserter, fileSystem);
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class StoreLockChecker method check.
/**
* Create store lock checker with lock on a provided path if it exists and writable
* @param databaseDirectory database path
* @return lock checker or empty closeable in case if path does not exists or is not writable
* @throws CannotWriteException
*
* @see StoreLocker
* @see Files
*/
static Closeable check(Path databaseDirectory) throws CannotWriteException {
Path lockFile = databaseDirectory.resolve(StoreLocker.STORE_LOCK_FILENAME);
if (Files.exists(lockFile)) {
if (Files.isWritable(lockFile)) {
StoreLockChecker storeLocker = new StoreLockChecker(new DefaultFileSystemAbstraction());
storeLocker.checkLock(databaseDirectory.toFile());
return storeLocker;
} else {
throw new CannotWriteException(lockFile);
}
}
return () -> {
};
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class VersionCommand method execute.
@Override
public void execute(String[] args) throws IncorrectUsage, CommandFailed {
final Path storeDir = arguments.parseMandatoryPath("store", args);
Validators.CONTAINS_EXISTING_DATABASE.validate(storeDir.toFile());
try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem)) {
final String storeVersion = new StoreVersionCheck(pageCache).getVersion(storeDir.resolve(MetaDataStore.DEFAULT_NAME).toFile()).orElseThrow(() -> new CommandFailed(String.format("Could not find version metadata in store '%s'", storeDir)));
final String fmt = "%-25s%s";
out.accept(String.format(fmt, "Store format version:", storeVersion));
RecordFormats format = RecordFormatSelector.selectForVersion(storeVersion);
out.accept(String.format(fmt, "Introduced in version:", format.introductionVersion()));
findSuccessor(format).map(next -> String.format(fmt, "Superseded in version:", next.introductionVersion())).ifPresent(out);
out.accept(String.format(fmt, "Current version:", Version.getNeo4jVersion()));
} catch (IOException e) {
throw new CommandFailed(e.getMessage(), e);
}
}
use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.
the class DumpCommandTest method shouldRespectTheStoreLock.
@Test
public void shouldRespectTheStoreLock() throws Exception {
Path databaseDirectory = homeDir.resolve("data/databases/foo.db");
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
StoreLocker storeLocker = new StoreLocker(fileSystem)) {
storeLocker.checkLock(databaseDirectory.toFile());
execute("foo.db");
fail("expected exception");
} catch (CommandFailed e) {
assertThat(e.getMessage(), equalTo("the database is in use -- stop Neo4j and try again"));
}
}
Aggregations