Search in sources :

Example 6 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class RsdrMain method main.

public static void main(String[] args) throws IOException {
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        console.printf("Neo4j Raw Store Diagnostics Reader%n");
        if (args.length != 1 || !fileSystem.isDirectory(new File(args[0]))) {
            console.printf("Usage: rsdr <store directory>%n");
            return;
        }
        File storedir = new File(args[0]);
        Config config = buildConfig();
        try (PageCache pageCache = createPageCache(fileSystem, config)) {
            File neoStore = new File(storedir, MetaDataStore.DEFAULT_NAME);
            StoreFactory factory = openStore(fileSystem, neoStore, config, pageCache);
            NeoStores neoStores = factory.openAllNeoStores();
            interact(fileSystem, neoStores);
        }
    }
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) ConfigurableStandalonePageCacheFactory.createPageCache(org.neo4j.kernel.impl.pagecache.ConfigurableStandalonePageCacheFactory.createPageCache)

Example 7 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class RebuildFromLogs method main.

public static void main(String[] args) throws Exception, InconsistentStoreException {
    if (args == null) {
        printUsage();
        return;
    }
    Args params = Args.parse(args);
    @SuppressWarnings("boxing") long txId = params.getNumber(UP_TO_TX_ID, BASE_TX_ID).longValue();
    List<String> orphans = params.orphans();
    args = orphans.toArray(new String[orphans.size()]);
    if (args.length != 2) {
        printUsage("Exactly two positional arguments expected: " + "<source dir with logs> <target dir for graphdb>, got " + args.length);
        System.exit(-1);
        return;
    }
    File source = new File(args[0]), target = new File(args[1]);
    if (!source.isDirectory()) {
        printUsage(source + " is not a directory");
        System.exit(-1);
        return;
    }
    if (target.exists()) {
        if (target.isDirectory()) {
            if (directoryContainsDb(target.toPath())) {
                printUsage("target graph database already exists");
                System.exit(-1);
                return;
            }
            System.err.println("WARNING: the directory " + target + " already exists");
        } else {
            printUsage(target + " is a file");
            System.exit(-1);
            return;
        }
    }
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        new RebuildFromLogs(fileSystem).rebuild(source, target, txId);
    }
}
Also used : Args(org.neo4j.helpers.Args) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) File(java.io.File)

Example 8 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class ApplyTransactionsCommand method applyTransactions.

private long applyTransactions(File fromPath, GraphDatabaseAPI toDb, long fromTxExclusive, long toTxInclusive, PrintStream out) throws IOException, TransactionFailureException {
    DependencyResolver resolver = toDb.getDependencyResolver();
    TransactionRepresentationCommitProcess commitProcess = new TransactionRepresentationCommitProcess(resolver.resolveDependency(TransactionAppender.class), resolver.resolveDependency(StorageEngine.class));
    LifeSupport life = new LifeSupport();
    try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
        PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem)) {
        LogicalTransactionStore source = life.add(new ReadOnlyTransactionStore(pageCache, fileSystem, fromPath, new Monitors()));
        life.start();
        long lastAppliedTx = fromTxExclusive;
        // Some progress if there are more than a couple of transactions to apply
        ProgressListener progress = toTxInclusive - fromTxExclusive >= 100 ? textual(out).singlePart("Application progress", toTxInclusive - fromTxExclusive) : ProgressListener.NONE;
        try (IOCursor<CommittedTransactionRepresentation> cursor = source.getTransactions(fromTxExclusive + 1)) {
            while (cursor.next()) {
                CommittedTransactionRepresentation transaction = cursor.get();
                TransactionRepresentation transactionRepresentation = transaction.getTransactionRepresentation();
                try {
                    commitProcess.commit(new TransactionToApply(transactionRepresentation), NULL, EXTERNAL);
                    progress.add(1);
                } catch (final Throwable e) {
                    System.err.println("ERROR applying transaction " + transaction.getCommitEntry().getTxId());
                    throw e;
                }
                lastAppliedTx = transaction.getCommitEntry().getTxId();
                if (lastAppliedTx == toTxInclusive) {
                    break;
                }
            }
        }
        return lastAppliedTx;
    } finally {
        life.shutdown();
    }
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) TransactionAppender(org.neo4j.kernel.impl.transaction.log.TransactionAppender) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) StorageEngine(org.neo4j.storageengine.api.StorageEngine) ReadOnlyTransactionStore(org.neo4j.kernel.impl.transaction.log.ReadOnlyTransactionStore) DependencyResolver(org.neo4j.graphdb.DependencyResolver) ProgressListener(org.neo4j.helpers.progress.ProgressListener) TransactionRepresentationCommitProcess(org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess) Monitors(org.neo4j.kernel.monitoring.Monitors) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) PageCache(org.neo4j.io.pagecache.PageCache)

Example 9 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class DumpClusterState method main.

/**
     * @param args [0] = data directory
     * @throws IOException When IO exception occurs.
     */
public static void main(String[] args) throws IOException, ClusterStateException {
    if (args.length != 1) {
        System.out.println("usage: DumpClusterState <data directory>");
        System.exit(1);
    }
    File dataDirectory = new File(args[0]);
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        DumpClusterState dumpTool = new DumpClusterState(fileSystem, dataDirectory, System.out);
        dumpTool.dump();
    }
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) File(java.io.File)

Example 10 with DefaultFileSystemAbstraction

use of org.neo4j.io.fs.DefaultFileSystemAbstraction in project neo4j by neo4j.

the class RestoreDatabaseCli method execute.

@Override
public void execute(String[] incomingArguments) throws IncorrectUsage, CommandFailed {
    String databaseName;
    String fromPath;
    boolean forceOverwrite;
    try {
        databaseName = arguments.parse("database", incomingArguments);
        fromPath = arguments.parse("from", incomingArguments);
        forceOverwrite = arguments.parseBoolean("force", incomingArguments);
    } catch (IllegalArgumentException e) {
        throw new IncorrectUsage(e.getMessage());
    }
    Config config = loadNeo4jConfig(homeDir, configDir, databaseName);
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        RestoreDatabaseCommand restoreDatabaseCommand = new RestoreDatabaseCommand(fileSystem, new File(fromPath), config, databaseName, forceOverwrite);
        restoreDatabaseCommand.execute();
    } catch (IOException e) {
        throw new CommandFailed("Failed to restore database", e);
    }
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) IncorrectUsage(org.neo4j.commandline.admin.IncorrectUsage) Config(org.neo4j.kernel.configuration.Config) CommandFailed(org.neo4j.commandline.admin.CommandFailed) IOException(java.io.IOException) File(java.io.File)

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