Search in sources :

Example 6 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j by neo4j.

the class ReadTestSupport method setup.

@Override
public void setup(Path storeDir, Consumer<GraphDatabaseService> create, Consumer<GraphDatabaseService> sysCreate) {
    DatabaseManagementServiceBuilder databaseManagementServiceBuilder = newManagementServiceBuilder(storeDir);
    databaseManagementServiceBuilder.setConfig(settings);
    managementService = databaseManagementServiceBuilder.build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
    GraphDatabaseService sysDb = managementService.database(SYSTEM_DATABASE_NAME);
    create.accept(db);
    sysCreate.accept(sysDb);
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder)

Example 7 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j-documentation by neo4j.

the class TransactionEventListenerExample method main.

// tag::TransactionEventListener[]
public static void main(String[] args) throws IOException {
    FileUtils.deleteDirectory(HOME_DIRECTORY);
    var managementService = new DatabaseManagementServiceBuilder(HOME_DIRECTORY).build();
    var database = managementService.database(DEFAULT_DATABASE_NAME);
    var countingListener = new CountingTransactionEventListener();
    managementService.registerTransactionEventListener(DEFAULT_DATABASE_NAME, countingListener);
    var connectionType = RelationshipType.withName("CONNECTS");
    try (var transaction = database.beginTx()) {
        var startNode = transaction.createNode();
        var endNode = transaction.createNode();
        startNode.createRelationshipTo(endNode, connectionType);
        transaction.commit();
    }
}
Also used : DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder)

Example 8 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j-documentation by neo4j.

the class OrderedPath method main.

public static void main(String[] args) {
    DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(databaseDirectory).build();
    GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    OrderedPath op = new OrderedPath(managementService, db);
    op.shutdownGraph();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Example 9 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j-documentation by neo4j.

the class StartWithConfigurationDocTest method loadFromHashmap.

@Test
void loadFromHashmap() {
    // tag::startDbWithMapConfig[]
    DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(directory).setConfig(GraphDatabaseSettings.pagecache_memory, ByteUnit.mebiBytes(512)).setConfig(GraphDatabaseSettings.transaction_timeout, Duration.ofSeconds(60)).setConfig(GraphDatabaseSettings.preallocate_logical_logs, true).build();
    GraphDatabaseService graphDb = managementService.database(DEFAULT_DATABASE_NAME);
    // end::startDbWithMapConfig[]
    Assertions.assertNotNull(graphDb);
    managementService.shutdown();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 10 with DatabaseManagementServiceBuilder

use of org.neo4j.dbms.api.DatabaseManagementServiceBuilder in project neo4j-documentation by neo4j.

the class OrderedPathDocTest method setUp.

@BeforeClass
public static void setUp() throws IOException {
    if (Files.exists(OrderedPath.databaseDirectory)) {
        FileUtils.deleteDirectory(OrderedPath.databaseDirectory);
    }
    DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(OrderedPath.databaseDirectory).build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
    orderedPath = new OrderedPath(managementService, OrderedPathDocTest.db);
    gen = new JavaDocsGenerator("ordered-path-java", "dev");
}
Also used : DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) JavaDocsGenerator(org.neo4j.doc.tools.JavaDocsGenerator) BeforeClass(org.junit.BeforeClass)

Aggregations

DatabaseManagementServiceBuilder (org.neo4j.dbms.api.DatabaseManagementServiceBuilder)30 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)19 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)13 Transaction (org.neo4j.graphdb.Transaction)11 Node (org.neo4j.graphdb.Node)10 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)10 Test (org.junit.jupiter.api.Test)9 Path (java.nio.file.Path)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 Test (org.junit.Test)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Disabled (org.junit.jupiter.api.Disabled)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Relationship (org.neo4j.graphdb.Relationship)2 RelationshipType (org.neo4j.graphdb.RelationshipType)2 Result (org.neo4j.graphdb.Result)2 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)2 EphemeralFileSystemAbstraction (org.neo4j.io.fs.EphemeralFileSystemAbstraction)2