Changing graphname at runtime
Hello,
https://docs.janusgraph.org/basics/configured-graph-factory/#updating-configurations
You can version your graph in the storage and indexing backends, but keep the graph name facing the end user the same.
Best wishes, Marc
// Create and open main graph
map = new HashMap();
map.put("storage.backend", “hbase);
map.put("storage.hostname", “xx.xx.xx.xx,yy.yy.yy.yy,zz.zz.zz.zz”);
map.put("storage.hbase.table”, “TABLE_A”);
map.put("graph.graphname", “GRAPH”);
configuration = new MapConfiguration(map);
configuration.setDelimiterParsingDisabled(True);
ConfiguredGraphFactory.createConfiguration(configuration);
graph = ConfiguredGraphFactory.open(“GRAPH”);
// Create, open and update replacement graph
map = new HashMap();
map.put("storage.backend", “hbase);
map.put("storage.hostname", “xx.xx.xx.xx,yy.yy.yy.yy,zz.zz.zz.zz”);
map.put("storage.hbase.table”, “TABLE_B”);
map.put("graph.graphname", “GRAPH_TEMP”);
configuration = new MapConfiguration(map);
configuration.setDelimiterParsingDisabled(True);
ConfiguredGraphFactory.createConfiguration(configuration);
graph = ConfiguredGraphFactory.open(“GRAPH_TEMP”);
// Modify GRAPH_TEMP and when it’s time to make that the live one:
map = new HashMap();
map.put("storage.hbase.table”, “TABLE_B);
ConfiguredGraphFactory.updateConfiguration(“GRAPH”,map);
graph = ConfiguredGraphFactory.open(“GRAPH”);
But that raises some additional questions:
- Do I need to ConfiguredGraphFactory.close(GRAPH) before I update its configuration?
- What happens to GRAPH_TEMP? Wouldn't it be still pointing to the same storage backend HBase table as GRAPH, i.e. to TABLE_B?
- if I want to reuse the same scheme, I'd have to have some logic that the next time around I need to renew GRAPH, I have GRAPH_TEMP talk to TABLE_A instead and then switch GRAPH to use TABLE_A, correct?
> Do I need to ConfiguredGraphFactory.close(GRAPH) before I update its configuration?
The docs say the binding between graph name and graph instance renews every 20 secs, so maybe this is not necessary.
> What happens to GRAPH_TEMP? Wouldn't it be still pointing to the same storage backend HBase table as GRAPH, i.e. to TABLE_B?
GRAPH_TEMP is just a name in the JanusGraphManager memory. It does not matter.
> if I want to reuse the same scheme, I'd have to have some logic that the next time around I need to renew GRAPH, I have GRAPH_TEMP talk to TABLE_A instead and then switch GRAPH to use TABLE_A, correct?
You are right. I would prefer straight versioning or a timestamp in the tablename, or the reuse of names will bite you some day. Of course, you would drop TABLE_A from the storage backend if not needed anymore.
Best wishes, Marc