Search in sources :

Example 46 with DefaultFileSystemAbstraction

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);
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) ManagementData(org.neo4j.jmx.impl.ManagementData) Before(org.junit.Before)

Example 47 with DefaultFileSystemAbstraction

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);
}
Also used : BatchInserterImpl(org.neo4j.unsafe.batchinsert.internal.BatchInserterImpl) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemClosingBatchInserter(org.neo4j.unsafe.batchinsert.internal.FileSystemClosingBatchInserter)

Example 48 with DefaultFileSystemAbstraction

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 () -> {
    };
}
Also used : Path(java.nio.file.Path) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction)

Example 49 with DefaultFileSystemAbstraction

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);
    }
}
Also used : MandatoryCanonicalPath(org.neo4j.commandline.arguments.common.MandatoryCanonicalPath) Path(java.nio.file.Path) PageCache(org.neo4j.io.pagecache.PageCache) Validators(org.neo4j.kernel.impl.util.Validators) StandalonePageCacheFactory(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory) Version(org.neo4j.kernel.internal.Version) IOException(java.io.IOException) RecordFormatSelector(org.neo4j.kernel.impl.store.format.RecordFormatSelector) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) AdminCommand(org.neo4j.commandline.admin.AdminCommand) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Consumer(java.util.function.Consumer) MandatoryCanonicalPath(org.neo4j.commandline.arguments.common.MandatoryCanonicalPath) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Arguments(org.neo4j.commandline.arguments.Arguments) OutsideWorld(org.neo4j.commandline.admin.OutsideWorld) RecordFormatSelector.findSuccessor(org.neo4j.kernel.impl.store.format.RecordFormatSelector.findSuccessor) MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) CommandFailed(org.neo4j.commandline.admin.CommandFailed) IncorrectUsage(org.neo4j.commandline.admin.IncorrectUsage) Path(java.nio.file.Path) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) CommandFailed(org.neo4j.commandline.admin.CommandFailed) IOException(java.io.IOException) PageCache(org.neo4j.io.pagecache.PageCache)

Example 50 with DefaultFileSystemAbstraction

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"));
    }
}
Also used : Path(java.nio.file.Path) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) StoreLocker(org.neo4j.kernel.internal.StoreLocker) CommandFailed(org.neo4j.commandline.admin.CommandFailed) Test(org.junit.Test)

Aggregations

DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)82 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)43 File (java.io.File)24 Path (java.nio.file.Path)21 PageCache (org.neo4j.io.pagecache.PageCache)21 Test (org.junit.Test)14 Test (org.junit.jupiter.api.Test)13 IOException (java.io.IOException)12 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)11 Config (org.neo4j.kernel.configuration.Config)11 Config (org.neo4j.configuration.Config)9 ThreadPoolJobScheduler (org.neo4j.test.scheduler.ThreadPoolJobScheduler)8 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)7 Transaction (org.neo4j.graphdb.Transaction)7 PrintStream (java.io.PrintStream)6 Before (org.junit.Before)6 CommandFailed (org.neo4j.commandline.admin.CommandFailed)6 Args (org.neo4j.helpers.Args)6 StandalonePageCacheFactory.createPageCache (org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache)6 JobScheduler (org.neo4j.scheduler.JobScheduler)6