use of org.neo4j.io.pagecache.PageCache 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.pagecache.PageCache in project neo4j by neo4j.
the class RebuildFromLogs method rebuild.
public void rebuild(File source, File target, long txId) throws Exception, InconsistentStoreException {
try (PageCache pageCache = StandalonePageCacheFactory.createPageCache(fs)) {
PhysicalLogFiles logFiles = new PhysicalLogFiles(source, fs);
long highestVersion = logFiles.getHighestLogVersion();
if (highestVersion < 0) {
printUsage("Inconsistent number of log files found in " + source);
return;
}
long txCount = findLastTransactionId(logFiles, highestVersion);
ProgressMonitorFactory progress;
if (txCount < 0) {
progress = ProgressMonitorFactory.NONE;
System.err.println("Unable to report progress, cannot find highest txId, attempting rebuild anyhow.");
} else {
progress = ProgressMonitorFactory.textual(System.err);
}
progress.singlePart(format("Rebuilding store from %s transactions ", txCount), txCount);
long lastTxId;
try (TransactionApplier applier = new TransactionApplier(fs, target, pageCache)) {
lastTxId = applier.applyTransactionsFrom(source, txId);
}
// set last tx id in neostore otherwise the db is not usable
MetaDataStore.setRecord(pageCache, new File(target, MetaDataStore.DEFAULT_NAME), MetaDataStore.Position.LAST_TRANSACTION_ID, lastTxId);
checkConsistency(target, pageCache);
}
}
use of org.neo4j.io.pagecache.PageCache 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.pagecache.PageCache in project neo4j by neo4j.
the class DumpCountsStore method dumpCountsStore.
public static void dumpCountsStore(FileSystemAbstraction fs, File path, PrintStream out) throws IOException {
try (PageCache pages = createPageCache(fs);
Lifespan life = new Lifespan()) {
if (fs.isDirectory(path)) {
StoreFactory factory = new StoreFactory(path, pages, fs, NullLogProvider.getInstance());
NeoStores neoStores = factory.openAllNeoStores();
SchemaStorage schemaStorage = new SchemaStorage(neoStores.getSchemaStore());
neoStores.getCounts().accept(new DumpCountsStore(out, neoStores, schemaStorage));
} else {
VisitableCountsTracker tracker = new VisitableCountsTracker(NullLogProvider.getInstance(), fs, pages, Config.empty(), path);
if (fs.fileExists(path)) {
tracker.visitFile(path, new DumpCountsStore(out));
} else {
life.add(tracker).accept(new DumpCountsStore(out));
}
}
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StartStopLoad method assertStoreConsistent.
private void assertStoreConsistent(String storeDir, KernelExtensions kernelExtensions) {
File fromDirectory = new File(storeDir);
File parent = fromDirectory.getParentFile();
try (TemporaryStoreDirectory storeDirectory = new TemporaryStoreDirectory(fs, pageCache, parent);
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fs)) {
fs.copyRecursively(fromDirectory, storeDirectory.storeDir());
new CopiedStoreRecovery(Config.defaults(), kernelExtensions.listFactories(), pageCache).recoverCopiedStore(storeDirectory.storeDir());
ConsistencyCheckService.Result result = runConsistencyCheckTool(new String[] { storeDir });
if (!result.isSuccessful()) {
throw new RuntimeException("Not consistent database in " + storeDir);
}
} catch (Throwable e) {
throw new RuntimeException("Failed to run CC on " + storeDir, e);
}
}
Aggregations