Search in sources :

Example 41 with GraphDatabaseService

use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.

the class CopiedStoreRecovery method recoverCopiedStore.

public synchronized void recoverCopiedStore(File tempStore) throws StoreCopyFailedException {
    if (shutdown) {
        throw new StoreCopyFailedException("Abort store-copied store recovery due to database shutdown");
    }
    try {
        GraphDatabaseService graphDatabaseService = newTempDatabase(tempStore);
        graphDatabaseService.shutdown();
    } catch (Exception e) {
        Throwable peeled = Exceptions.peel(e, (t) -> !(t instanceof UpgradeNotAllowedByConfigurationException));
        if (peeled != null) {
            throw new RuntimeException(failedToStartMessage(), e);
        } else {
            throw e;
        }
    }
}
Also used : PageCache(org.neo4j.io.pagecache.PageCache) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter) Config(org.neo4j.kernel.configuration.Config) Exceptions(org.neo4j.helpers.Exceptions) Settings(org.neo4j.kernel.configuration.Settings) NullLogProvider(org.neo4j.logging.NullLogProvider) File(java.io.File) LabelIndex(org.neo4j.graphdb.factory.GraphDatabaseSettings.LabelIndex) UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) ExternallyManagedPageCache.graphDatabaseFactoryWithPageCache(org.neo4j.com.storecopy.ExternallyManagedPageCache.graphDatabaseFactoryWithPageCache) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) GraphDatabaseSettings(org.neo4j.graphdb.factory.GraphDatabaseSettings) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException)

Example 42 with GraphDatabaseService

use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.

the class TestConfiguration method testEnableDefaultsInConfig.

@Test
public void testEnableDefaultsInConfig() throws Exception {
    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(SOURCE_DIR).setConfig(OnlineBackupSettings.online_backup_enabled, Settings.TRUE).newGraphDatabase();
    OnlineBackup.from(HOST_ADDRESS).full(BACKUP_DIR);
    db.shutdown();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Test(org.junit.Test)

Example 43 with GraphDatabaseService

use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.

the class RestoreDatabaseCommandTest method shouldAllowForcedCopyOverAnExistingDatabase.

@Test
public void shouldAllowForcedCopyOverAnExistingDatabase() throws Exception {
    // given
    String databaseName = "to";
    Config config = configWith(Config.empty(), databaseName, directory.absolutePath().getAbsolutePath());
    File fromPath = new File(directory.absolutePath(), "from");
    File toPath = config.get(DatabaseManagementSystemSettings.database_path);
    int fromNodeCount = 10;
    int toNodeCount = 20;
    createDbAt(fromPath, fromNodeCount);
    createDbAt(toPath, toNodeCount);
    // when
    new RestoreDatabaseCommand(fileSystemRule.get(), fromPath, config, databaseName, true).execute();
    // then
    GraphDatabaseService copiedDb = new GraphDatabaseFactory().newEmbeddedDatabase(toPath);
    try (Transaction ignored = copiedDb.beginTx()) {
        assertEquals(fromNodeCount, Iterables.count(copiedDb.getAllNodes()));
    }
    copiedDb.shutdown();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) GraphDatabaseFactory(org.neo4j.graphdb.factory.GraphDatabaseFactory) Config(org.neo4j.kernel.configuration.Config) File(java.io.File) Test(org.junit.Test)

Example 44 with GraphDatabaseService

use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.

the class BiggerThanLogTxIT method assertAllMembersHasNodeCount.

private void assertAllMembersHasNodeCount(long expectedNodeCount) {
    for (GraphDatabaseService db : cluster.getAllMembers()) {
        // Try again with sync, it will clear up...
        if (expectedNodeCount != nodeCount(db)) {
            for (int i = 0; i < 100; i++) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                long count = nodeCount(db);
                if (expectedNodeCount == count) {
                    break;
                }
                cluster.sync();
            }
        }
        assertEquals(expectedNodeCount, nodeCount(db));
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService)

Example 45 with GraphDatabaseService

use of org.neo4j.graphdb.GraphDatabaseService in project neo4j by neo4j.

the class MeasureUpdatePullingRecordAndIndexGap method awaitIndexes.

private void awaitIndexes(ManagedCluster cluster) {
    for (GraphDatabaseService db : cluster.getAllMembers()) {
        try (Transaction tx = db.beginTx()) {
            db.schema().awaitIndexesOnline(1, MINUTES);
            tx.success();
        }
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction)

Aggregations

GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)322 Test (org.junit.Test)225 Transaction (org.neo4j.graphdb.Transaction)182 Node (org.neo4j.graphdb.Node)142 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)77 File (java.io.File)70 Relationship (org.neo4j.graphdb.Relationship)49 EmbeddedGraphDatabase (org.neo4j.kernel.EmbeddedGraphDatabase)32 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)17 Result (org.neo4j.graphdb.Result)14 Label (org.neo4j.graphdb.Label)13 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)12 HashMap (java.util.HashMap)11 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 PageCache (org.neo4j.io.pagecache.PageCache)10 DbRepresentation (org.neo4j.test.DbRepresentation)10 GraphDatabaseFactory (org.neo4j.graphdb.factory.GraphDatabaseFactory)9 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)8