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);
}
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();
}
}
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();
}
}
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: ");
}
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();
}
Aggregations