4

I have a running instance of JanusGraph Server and I can connect using EmptyGraph for read and write. But I cannot use EmptyGraph to create an instance of JanusGraphManagement. I want to use the API to define my schema but the only options I can find are:

  • use Cluster to create a Client to submit command strings
  • connect an embedded JanusGraph instance directly to my Cassandra backend

I prefer to do everything through the JanusGraph Server. Is there a way to do this using the Java API? Or am I stuck with only the two above options?

Mark J Miller
  • 4,751
  • 5
  • 44
  • 74
  • Janusgraph can be obtained using - JanusGraphFactory.open("conf/janusgraph-cassandra.properties"). – Ajay Srivastava Mar 28 '19 at 16:29
  • That connects to the cassandra backend (unless you want to elaborate with an example configuration file). I've stated that I know I can do that. My question is can I create a JanusGraph instance which is connected to JanusGraph Server instead of the storage backend? – Mark J Miller Mar 28 '19 at 16:39
  • 1
    Sorry. I replied in a hurry. I guess that there are only two options as described by you. Embedded instance is good for creating schema as the operation is not so frequent, most likely will be done once only. – Ajay Srivastava Mar 28 '19 at 17:49
  • maybe this answer will help ! [here](https://stackoverflow.com/questions/45673861/how-can-i-remotely-connect-to-a-janusgraph-server) – Tony IronMan Aug 01 '19 at 23:08
  • Did you ever figure this one out? :) – Jarvis May 06 '20 at 10:37
  • 1
    @Jarvis There are ways to do this in java [see my example](https://github.com/baughmann/janusgraph-configuredgraphfactory-java-demo/blob/7c4f89882d8c50280a3e78556384dee88e0bdd22/janusgraph-configuredgraphfactory-demo/src/main/kotlin/Main.kt#L29) but it should be avoided. `client.submit()` using a `Client.SessionedClient` should be used instead to perform management tasks. See the end of my answer [here](https://stackoverflow.com/a/74721551/2763058) – foxtrotuniform6969 Dec 08 '22 at 21:02
  • @Jarvis Also check this [gist I made](https://gist.github.com/baughmann/3336984f2f0f43fa6d20f4b9b821eac1) – foxtrotuniform6969 Dec 08 '22 at 21:34

1 Answers1

1

As described in the updated docs of JanusGraph here:

The described connection uses GraphBinary and the janusgraph-driver which doesn't allow accessing the internal JanusGraph components such as ManagementSystem. To access the ManagementSystem, you have to submit java-based scripts, see Submitting Scripts, or directly accessing JanusGraph by local opening a JanusGraph instance.

So for now, no other options exists.

unautre
  • 191
  • 3
  • 11
  • 1
    To add an example (in Kotlin): ```kotlin // get a session so that you can use the management instance and save variables on the server side val cluster = Cluster.build("localhost").create() val session = cluster.connect() // now get a management system instance client.submit("mgmt = ConfiguredGraphFactory.open('myGraph').openManagement()").all().get() // afterwards you can use it: client.submit("// do stuff with mgmt").all().get() // don't forget to close your session!! session.close() ``` See my answer [here](https://stackoverflow.com/a/74721551/2763058) – foxtrotuniform6969 Dec 08 '22 at 20:58
  • 1
    Better yet, [here's a gist](https://gist.github.com/baughmann/3336984f2f0f43fa6d20f4b9b821eac1) – foxtrotuniform6969 Dec 08 '22 at 21:35