Search in sources :

Example 96 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class UniqueConstraintCompatibility method resolveInternalDependency.

private <T> T resolveInternalDependency(Class<T> type) {
    GraphDatabaseAPI api = (GraphDatabaseAPI) db;
    DependencyResolver resolver = api.getDependencyResolver();
    return resolver.resolveDependency(type);
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) DependencyResolver(org.neo4j.common.DependencyResolver)

Example 97 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class DatabaseManagementServiceBuilderIT method startSystemAndDefaultDatabase.

@Test
void startSystemAndDefaultDatabase() {
    DatabaseManagementService managementService = getDbmsBuilderWithLimitedTxLogSize(testDirectory.homePath()).build();
    GraphDatabaseAPI database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    try {
        DependencyResolver dependencyResolver = database.getDependencyResolver();
        DatabaseManager<?> databaseManager = dependencyResolver.resolveDependency(DatabaseManager.class);
        assertThat(databaseManager.getDatabaseContext(DEFAULT_DATABASE_NAME)).isNotEmpty();
        assertThat(databaseManager.getDatabaseContext(NAMED_SYSTEM_DATABASE_ID)).isNotEmpty();
    } finally {
        managementService.shutdown();
    }
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) DependencyResolver(org.neo4j.common.DependencyResolver) Test(org.junit.jupiter.api.Test)

Example 98 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class DeepRelationshipTraversalCursorTestBase method createTestGraph.

@Override
public void createTestGraph(GraphDatabaseService graphDb) {
    try (Transaction tx = graphDb.beginTx()) {
        Node root = tx.createNode();
        three_root = root.getId();
        Node[] leafs = new Node[32];
        for (int i = 0; i < leafs.length; i++) {
            leafs[i] = tx.createNode();
        }
        int offset = 0, duplicate = 12;
        Node interdup = tx.createNode();
        interdup.createRelationshipTo(root, PARENT);
        offset = relate(duplicate, leafs, offset, interdup);
        for (int i = 0; i < 5; i++) {
            Node inter = tx.createNode();
            inter.createRelationshipTo(root, PARENT);
            offset = relate(3 + i, leafs, offset, inter);
        }
        interdup.createRelationshipTo(root, PARENT);
        for (int i = 0; i < 4; i++) {
            Node inter = tx.createNode();
            inter.createRelationshipTo(root, PARENT);
            offset = relate(2 + i, leafs, offset, inter);
        }
        Node inter = tx.createNode();
        inter.createRelationshipTo(root, PARENT);
        offset = relate(1, leafs, offset, inter);
        expected_total = offset + duplicate;
        expected_unique = leafs.length;
        parentRelationshipTypeId = ((GraphDatabaseAPI) graphDb).getDependencyResolver().resolveDependency(TokenHolders.class).relationshipTypeTokens().getIdByName(PARENT.name());
        tx.commit();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Node(org.neo4j.graphdb.Node) TokenHolders(org.neo4j.token.TokenHolders)

Example 99 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class TestReadOnlyNeo4j method databaseNotStartInReadOnlyModeWithMissingIndex.

@Test
void databaseNotStartInReadOnlyModeWithMissingIndex() throws IOException {
    createIndex();
    deleteIndexFolder();
    AssertableLogProvider logProvider = new AssertableLogProvider();
    managementService = dbmsReadOnly(logProvider);
    final var db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    var namedDatabaseId = db.databaseId();
    assertFalse(db.isAvailable(1L), "Did not expect db to start");
    assertThat(logProvider).assertExceptionForLogMessage("[" + namedDatabaseId.logPrefix() + "] Exception occurred while starting the database. Trying to stop already started components.").hasMessageContaining("Some indexes need to be rebuilt. This is not allowed in read only mode. Please start db in " + "writable mode to rebuild indexes. Indexes needing rebuild: ");
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 100 with GraphDatabaseAPI

use of org.neo4j.kernel.internal.GraphDatabaseAPI in project neo4j by neo4j.

the class TestShutdownSequence method canRemoveFilesAndReinvokeShutdown.

@Test
void canRemoveFilesAndReinvokeShutdown() throws IOException {
    GraphDatabaseAPI databaseAPI = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    FileSystemAbstraction fileSystemAbstraction = getDatabaseFileSystem(databaseAPI);
    managementService.shutdown();
    fileSystemAbstraction.deleteRecursively(databaseAPI.databaseLayout().databaseDirectory());
    managementService.shutdown();
}
Also used : FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Test(org.junit.jupiter.api.Test)

Aggregations

GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)262 Test (org.junit.Test)91 Test (org.junit.jupiter.api.Test)88 Transaction (org.neo4j.graphdb.Transaction)87 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)61 Node (org.neo4j.graphdb.Node)38 Path (java.nio.file.Path)30 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)30 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)28 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)26 File (java.io.File)25 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)24 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)19 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)18 DependencyResolver (org.neo4j.graphdb.DependencyResolver)17 Label (org.neo4j.graphdb.Label)15 PageCache (org.neo4j.io.pagecache.PageCache)15 Config (org.neo4j.kernel.configuration.Config)15 DatabaseStateService (org.neo4j.dbms.DatabaseStateService)14 IOException (java.io.IOException)11