Search in sources :

Example 81 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestUpgradeStore method makeSureStoreCantBeUpgradedByBatchInserterEvenIfExplicitlyToldTo.

@Test
public void makeSureStoreCantBeUpgradedByBatchInserterEvenIfExplicitlyToldTo() throws Exception {
    String path = path(14);
    new EmbeddedGraphDatabase(path).shutdown();
    setOlderNeoStoreVersion(path);
    try {
        new BatchInserterImpl(path, stringMap(ALLOW_STORE_UPGRADE, "true"));
        fail("Shouldn't be able to upgrade with batch inserter");
    } catch (IllegalArgumentException e) {
    // Good
    }
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) BatchInserterImpl(org.neo4j.kernel.impl.batchinsert.BatchInserterImpl) Test(org.junit.Test)

Example 82 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestUpgradeStore method makeSureStoreCanBeUpgradedIfExplicitlyToldTo.

@Test
public void makeSureStoreCanBeUpgradedIfExplicitlyToldTo() throws Exception {
    String path = path(13);
    new EmbeddedGraphDatabase(path).shutdown();
    setOlderNeoStoreVersion(path);
    new EmbeddedGraphDatabase(path, stringMap(ALLOW_STORE_UPGRADE, "true")).shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) Test(org.junit.Test)

Example 83 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase 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 84 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project qi4j-sdk by Qi4j.

the class NeoEntityStoreMixin method activateService.

@Override
public void activateService() throws Exception {
    String path = config.get().path().get();
    if (path == null) {
        if (fileConfiguration != null)
            path = new File(fileConfiguration.dataDirectory(), config.get().identity().get()).getAbsolutePath();
        else
            path = "build/neodb";
    }
    neo = new EmbeddedGraphDatabase(path);
    indexService = new LuceneIndexService(neo);
    uuid = UUID.randomUUID().toString() + "-";
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) LuceneIndexService(org.neo4j.index.lucene.LuceneIndexService) File(java.io.File)

Aggregations

EmbeddedGraphDatabase (org.neo4j.kernel.EmbeddedGraphDatabase)84 Test (org.junit.Test)50 File (java.io.File)35 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)32 Node (org.neo4j.graphdb.Node)26 Transaction (org.neo4j.graphdb.Transaction)17 Relationship (org.neo4j.graphdb.Relationship)14 BeforeClass (org.junit.BeforeClass)13 HashMap (java.util.HashMap)7 BatchInserterImpl (org.neo4j.kernel.impl.batchinsert.BatchInserterImpl)6 RandomAccessFile (java.io.RandomAccessFile)5 BatchInserter (org.neo4j.kernel.impl.batchinsert.BatchInserter)5 BatchInserterIndex (org.neo4j.graphdb.index.BatchInserterIndex)4 TransactionManager (javax.transaction.TransactionManager)3 Before (org.junit.Before)3 DynamicRelationshipType (org.neo4j.graphdb.DynamicRelationshipType)3 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)3 BatchInserterIndexProvider (org.neo4j.graphdb.index.BatchInserterIndexProvider)3 IndexManager (org.neo4j.graphdb.index.IndexManager)3 Transaction (javax.transaction.Transaction)2