Search in sources :

Example 1 with ProgressMonitorFactory

use of org.neo4j.helpers.progress.ProgressMonitorFactory 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);
    }
}
Also used : ProgressMonitorFactory(org.neo4j.helpers.progress.ProgressMonitorFactory) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) ExternallyManagedPageCache(org.neo4j.com.storecopy.ExternallyManagedPageCache) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)

Aggregations

File (java.io.File)1 ExternallyManagedPageCache (org.neo4j.com.storecopy.ExternallyManagedPageCache)1 ProgressMonitorFactory (org.neo4j.helpers.progress.ProgressMonitorFactory)1 PageCache (org.neo4j.io.pagecache.PageCache)1 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)1 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)1