Reputation: 3908
I'm trying to create multiple graph instances in Janusgraph, but they all seem to have the same reference to one another, and so any action taken on one affects the others (see example below). I want to have these graphs setup as separate instances, distinct from each other, but somewhere in the steps below I'm faltering.
Goal: have two graphs called graph1
, graph2
, with traversal objects named g1
, g2
, respectively, and which are distinct from one another.
Create properties files called graph1.properties
, graph2.properties
. With contents (for a Cassandra backend):
gremlin.graph=org.janusgraph.core.JanusGraphFactory
gremlin.graph=org.janusgraph.core.ConfiguredGraphFactory
storage.backend=cql
storage.hostname=127.0.0.1
^ This is where I'm guessing the core issue lies - graph1.properties
and graph2.properties
have the same contents... but I'm unsure what to change
Add the graphs to the gremlin-server.yaml
file, which maps to the newly created graph1.properties
and graph2.properties
files.
graphs: {
graph1: conf/gremlin-server/graph1.properties,
graph2: conf/gremlin-server/graph2.properties
}
Add traversal object names to the empty-sample.groovy
globals << [g1 : graph1.traversal(), g2: graph2.traversal()]
The output below shows that the graphs were created successfully, but also shows that they are referencing eachother.
==>Configured localhost/127.0.0.1:8182-[b7696535-97d9-4b59-b30f-f83707492057]
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182]-[b7696535-97d9-4b59-b30f-f83707492057] - type ':remote console' to return to local mode
gremlin> g1
==>graphtraversalsource[standardjanusgraph[cql:[127.0.0.1]], standard]
gremlin> g1.V().count()
==>100
gremlin> g2.V().count()
==>100
gremlin> g1.addV('item').property('id', '123')
==>v[327684312]
gremlin> g1.tx().commit()
==>null
gremlin> g1.V().count()
==>101
gremlin> g2.V().count()
==>101 <-- g2 should have remained at 100
Upvotes: 2
Views: 1283
Reputation: 13424
Since you're using Cassandra to store your data, to separate two graphs from each other entirely, you need to use a different Cassandra keyspace for each graph, as that's the unit of storage that JanusGraph uses.
As you can see in the JanusGraph Cassandra docs:
- keyspace: The name of the keyspace to store the JanusGraph graph in. Allows multiple JanusGraph graphs to co-exist in the same Cassandra cluster.
Looking at the JanusGraph configuration reference, we see more information about this configuration parameter:
- name:
storage.cql.keyspace
- description: "The name of JanusGraph’s keyspace. It will be created if it does not exist."
- data type:
String
- default value:
janusgraph
- mutability:
LOCAL
So, by not specifying this parameter in your config, both graphs are being stored in the default janusgraph
keyspace which causes them to conflict with each other.
Since you're using storage.backend=cql
, to separate the two graphs, simply provide an explicit parameter storage.cql.keyspace
which is different for each of the graphs you want to separate from each other.
Upvotes: 2