0
votes

Could you tell me - Is it possible to use OGM FERMA framework over Gremlin Server (TinkerPop 3.2.6 with JanusGraphDB on backend)?

For now I use gremlin client for sending queries to G-server in this way:

GryoMapper mapper = GryoMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()).create();
MessageSerializer serializer = new GryoMessageSerializerV1d0(GryoMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()));

/* Create gremlin cluster... */
Cluster cluster = Cluster.build("123.22.22.111").port(8182).serializer(serializer).create();
Client client = cluster.connect();
ResultSet res = client.submit("g.V().label()");

... therefore I have not idea about how could I get graph instance directly (like in the ferma tutorial):

FramedGraph fg = new DelegatingFramedGraph(graph, true, types);

... to use traversal for getting instances of ferma-annotated classes.

3

3 Answers

6
votes

Ferma is designed to work with embedded TinkerPop-enabled Graph instances. Therefore, it does not work with graphs hosted in Gremlin Server or remote graph providers like DSE Graph, CosmosDB, Neptune, etc.

3
votes

I am the lead developer of Ferma

Ferma is 100% compatible with all databases that TinkerPop is compatible with. Ferma acts as a thin wrapper around TinkerPop in order to provide the OGM layer. As long as you can provide a TinkerPop Graph object to Ferma then it can wrap it and use it.

That means if you want to use Ferma you will need to use a different approach. It is compatible with JanusGraph just fine but not through the Gremlin Server approach. You will have to use the TinkerPop graph drivers directly. In other words, wrap the graph object directly, which is an approach compatible with JanusGraph.

As mentioned in the other answer you can get a Graph object with the following call and then simply pass this object to Ferma's FramedGraph constructor.

Graph graph = JanusGraphFactory.open('cassandra:localhost')

2
votes

Ferma also supports many databases compatible with TinkerPop. How well it works is based on how well/fully the vendor's driver implements support for Tinkerpop.

For example, as I recently found out, DSE Graph does not work with it. A connected tinkerepop graph object is required for ORM traversal, and that's not something the DSE Graph driver supports. I was able to use Ferma for an object's simple properties, but none of the relationship would work.

It does work for Titan and other graph databases remotely. The README.md for support for JanusGraph was added to the Ferma repo in October.

If your cluster is already configured, you can use something like this to get the graph object:

Graph graph = JanusGraphFactory.open('cassandra:localhost')