Search in sources :

Example 1 with VisibleMigrationProgressMonitor

use of org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor in project neo4j by neo4j.

the class StoreMigration method run.

public void run(final FileSystemAbstraction fs, final File storeDirectory, Config config, LogProvider userLogProvider) throws IOException {
    StoreLogService logService = StoreLogService.withUserLogProvider(userLogProvider).inLogsDirectory(fs, storeDirectory);
    VisibleMigrationProgressMonitor progressMonitor = new VisibleMigrationProgressMonitor(logService.getUserLog(StoreMigration.class));
    LifeSupport life = new LifeSupport();
    life.add(logService);
    // Add participants from kernel extensions...
    LegacyIndexProvider legacyIndexProvider = new LegacyIndexProvider();
    Log log = userLogProvider.getLog(StoreMigration.class);
    try (PageCache pageCache = createPageCache(fs, config)) {
        Dependencies deps = new Dependencies();
        deps.satisfyDependencies(fs, config, legacyIndexProvider, pageCache, logService);
        KernelContext kernelContext = new SimpleKernelContext(storeDirectory, DatabaseInfo.UNKNOWN, deps);
        KernelExtensions kernelExtensions = life.add(new KernelExtensions(kernelContext, GraphDatabaseDependencies.newDependencies().kernelExtensions(), deps, ignore()));
        // Add the kernel store migrator
        life.start();
        SchemaIndexProvider schemaIndexProvider = kernelExtensions.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance());
        LabelScanStoreProvider labelScanStoreProvider = kernelExtensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config));
        long startTime = System.currentTimeMillis();
        DatabaseMigrator migrator = new DatabaseMigrator(progressMonitor, fs, config, logService, schemaIndexProvider, labelScanStoreProvider, legacyIndexProvider.getIndexProviders(), pageCache, RecordFormatSelector.selectForConfig(config, userLogProvider));
        migrator.migrate(storeDirectory);
        long duration = System.currentTimeMillis() - startTime;
        log.info(format("Migration completed in %d s%n", duration / 1000));
    } catch (Exception e) {
        throw new StoreUpgrader.UnableToUpgradeException("Failure during upgrade", e);
    } finally {
        life.shutdown();
    }
}
Also used : SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) VisibleMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor) StoreLogService(org.neo4j.kernel.impl.logging.StoreLogService) Log(org.neo4j.logging.Log) IOException(java.io.IOException) DatabaseMigrator(org.neo4j.kernel.impl.storemigration.DatabaseMigrator) KernelExtensions(org.neo4j.kernel.extension.KernelExtensions) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) Dependencies(org.neo4j.kernel.impl.util.Dependencies) GraphDatabaseDependencies(org.neo4j.kernel.GraphDatabaseDependencies) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) NamedLabelScanStoreSelectionStrategy(org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy) PageCache(org.neo4j.io.pagecache.PageCache) ConfigurableStandalonePageCacheFactory.createPageCache(org.neo4j.kernel.impl.pagecache.ConfigurableStandalonePageCacheFactory.createPageCache) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) KernelContext(org.neo4j.kernel.impl.spi.KernelContext)

Example 2 with VisibleMigrationProgressMonitor

use of org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor in project neo4j-mobile-android by neo4j-contrib.

the class StoreMigrationTool method run.

private void run(String legacyStoreDirectory, String targetStoreDirectory) throws IOException {
    LegacyStore legacyStore = new LegacyStore(new File(new File(legacyStoreDirectory), NeoStore.DEFAULT_NAME).getPath());
    HashMap config = new HashMap();
    config.put(IdGeneratorFactory.class, CommonFactories.defaultIdGeneratorFactory());
    config.put(FileSystemAbstraction.class, CommonFactories.defaultFileSystemAbstraction());
    File targetStoreDirectoryFile = new File(targetStoreDirectory);
    if (targetStoreDirectoryFile.exists()) {
        throw new IllegalStateException("Cannot migrate to a directory that already exists, please delete first and re-run");
    }
    boolean success = targetStoreDirectoryFile.mkdirs();
    if (!success) {
        throw new IllegalStateException("Failed to create directory");
    }
    File targetStoreFile = new File(targetStoreDirectory, NeoStore.DEFAULT_NAME);
    config.put("neo_store", targetStoreFile.getPath());
    NeoStore.createStore(targetStoreFile.getPath(), config);
    NeoStore neoStore = new NeoStore(config);
    long startTime = System.currentTimeMillis();
    new StoreMigrator(new VisibleMigrationProgressMonitor(System.out)).migrate(legacyStore, neoStore);
    long duration = System.currentTimeMillis() - startTime;
    System.out.printf("Migration completed in %d s%n", duration / 1000);
    neoStore.close();
    EmbeddedGraphDatabase database = new EmbeddedGraphDatabase(null, targetStoreDirectoryFile.getPath());
    database.shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) VisibleMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor) HashMap(java.util.HashMap) NeoStore(org.neo4j.kernel.impl.nioneo.store.NeoStore) LegacyStore(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStore) File(java.io.File)

Example 3 with VisibleMigrationProgressMonitor

use of org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor in project neo4j by neo4j.

the class NeoStoreDataSource method upgradeStore.

private void upgradeStore(RecordFormats format) {
    VisibleMigrationProgressMonitor progressMonitor = new VisibleMigrationProgressMonitor(logService.getUserLog(StoreMigrator.class));
    new DatabaseMigrator(progressMonitor, fs, config, logService, schemaIndexProvider, labelScanStoreProvider, indexProviders, pageCache, format).migrate(storeDir);
}
Also used : VisibleMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor) DatabaseMigrator(org.neo4j.kernel.impl.storemigration.DatabaseMigrator) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)

Aggregations

VisibleMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.VisibleMigrationProgressMonitor)3 DatabaseMigrator (org.neo4j.kernel.impl.storemigration.DatabaseMigrator)2 File (java.io.File)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 PageCache (org.neo4j.io.pagecache.PageCache)1 EmbeddedGraphDatabase (org.neo4j.kernel.EmbeddedGraphDatabase)1 GraphDatabaseDependencies (org.neo4j.kernel.GraphDatabaseDependencies)1 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)1 KernelExtensions (org.neo4j.kernel.extension.KernelExtensions)1 NamedLabelScanStoreSelectionStrategy (org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy)1 LabelScanStoreProvider (org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider)1 StoreLogService (org.neo4j.kernel.impl.logging.StoreLogService)1 NeoStore (org.neo4j.kernel.impl.nioneo.store.NeoStore)1 ConfigurableStandalonePageCacheFactory.createPageCache (org.neo4j.kernel.impl.pagecache.ConfigurableStandalonePageCacheFactory.createPageCache)1 KernelContext (org.neo4j.kernel.impl.spi.KernelContext)1 SimpleKernelContext (org.neo4j.kernel.impl.spi.SimpleKernelContext)1 StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)1 LegacyStore (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStore)1 StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)1