2

I am using gremlin server with hbase as back-end.I read that for storing multiple graphs we have to go with distinct tables,so I have multiple graphs stored in hbase under different table names.

The property storage.hbase.tablename is specified in titan-hbase.properties .But I have to provide the graph dynamically depending on the group and I cannot specify the table name in hbase.properties file(there can be hundreds of graphs).

What is the way to achieve this?

Nithin A
  • 374
  • 1
  • 2
  • 18

2 Answers2

2

When using versions of TinkerPop through 3.2.4, you would have to write a wrapper around Gremlin Server where you start it with something like:

Settings settings = new Settings()
GremlinServer server = new GremlinServer(settings);
server.start().join();

Then you would manipulate the GraphManager which you can get from the GremlinServer instance with:

GraphManager manager = server.getServerGremlinExecutor().getGraphManager() 

GraphManager.getGraphs() returns the Map<String,Graph> instance where you can dynamically add/remove the graphs that are being served. I would consider this method a hack/workaround to accomplish what you want, but there isn't another method.

As of 3.2.5 (as of this writing not released) and forward, GraphManager is an interface which you can implement yourself to dynamically provide your graph list. Your implementation can be referenced in the Gremlin Server configuration file thus allowing it to be plugged into the server dynamically.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Is it possible to do it on remote gremlin server ? `Settings settings = new Settings(); settings.port = 8182; settings.host = "192.168.1.65"; server.start().join();` This throws `java.io.IOException: Could not bind to 192.168.1.65 and 8182 - perhaps something else is bound to that address` – Manoj Suthar Jun 26 '17 at 13:28
  • i'm sorry - i don't know what you're asking exactly. if you're sending that script to a running gremlin server then it will fail because you are telling it to start a Gremlin Server on port 8182 which is the same port as the one that's already running to process the script. change the port and i would assume it would start though you just might hit another error. anyway, if that's what you're doing i can't say i'd recommend it. – stephen mallette Jun 26 '17 at 14:43
  • I want to start the server remotely by providing settings of remote machine. Found an example here: https://github.com/pluradj/titan-tp3-driver-example/blob/master/src/test/java/pluradj/titan/tinkerpop3/example/ServiceTest.java , which is close to what you mentioned here, but the configurations passed to it has host as localhost. – Manoj Suthar Jun 26 '17 at 15:03
1

He still needs a way to instantiate the graph references, though. And since the user doesn't want to create/edit their .properties file, what you can do is dynamically create a Configuration object based on a "shared" properties file and append the hbase tablename as a property on that configuration object, and use the GraphFactory to instantiate the graph object. Then, you may store the graph in the GraphManager's Map named by the tablename, or whatever you like. This last step is not necessary, however, the graph being stored there gains you auto commit and rollback functionality at the end of your Gremlin script executions.

David
  • 486
  • 2
  • 9