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);
}
}
}
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);
}
}
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();
}
}
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();
}
}
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);
}
}
Aggregations