Search code examples
orientdb

Distributing OrientDB using OrientGraphFactory


I am currently in a team developing a web application, and we are looking to use OrientDB 2.1 in the application. We want to use an embedded database, and the application will be run on two (or more) nodes, with a load balancer in front. We are also using Spring-boot and embedded Jetty.

One of the features that we need is that the database work in distributed mode, so changes are propagated to the other node(s).

Currently I am connecting to the graph using OrientGraphFactory like this:

private static OrientGraphFactory factory = new OrientGraphFactory("plocal:pathToDB").setupPool(1,10);

This is a very comfortable way of connecting, but I haven't found how to use this in an distributed environment. My questing is: Is there any way to use an embedded OrientDB like this, but running it distributed (for example using Hazelcast)? Or do we need to use OServer class?

Any help would be greatly appreciated.

-Knut


Solution

  • To answer my own question: As far as I have found, this is not possible. What I ended up doing is first starting the server using the OServerMain class like this:

    databaseServer = OServerMain.create(true);
    databaseServer.startup(cfg);
    

    I pass a OServerConfiguration object, and this object contains the Hazelcast plugin configuration, as well as the normal server configuration. And then connect using the factory like this:

    factory = new OrientGraphFactory("remote:127.0.0.1/test", user, password).setupPool(1,10);
    

    This also allows me to connect using the console application, and the web application if this is configured. I believe it's also possible to create the factory like this:

    factory = new OrientGraphFactory("plocal:path/to/db/test").setupPool(1,10);
    

    And the database will handle both connections, but I have not tried this properly yet.