0
votes

I have a docker container running the gremlin-server.

It was started via:

./bin/gremlin-server.sh conf/gremlin-server/gremlin-server.yaml

From within a docker container, running this image: https://hub.docker.com/r/janusgraph/janusgraph

The server is up and is listening at port 8182

$ docker ps
6019adda6081        janusgraph/janusgraph                                         "docker-entrypoint.s…"   2 days ago          Up 26 hours         0.0.0.0:8182->8182/tcp                             

I am interested in using a schema and indexes.

Janus offers this here: https://docs.janusgraph.org/basics/schema/

The following Is the configuration I use to attempt to connect to the gremlin-server:

AbstractConfiguration config = new BaseConfiguration();

    config.setListDelimiter('/');
    // contents of conf/remote-graph.properties
    config.setProperty("gremlin.remote.driver.sourceName", "g");
    config.setProperty("gremlin.remote.remoteConnectionClass", "org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection");
    // contents of conf/remote-objects.yaml:
    config.setProperty("clusterConfiguration.hosts", databaseUrl);
    config.setProperty("clusterConfiguration.port", 8182);
    config.setProperty("clusterConfiguration.serializer.className", "org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0/");

    config.setProperty("storage.backend", "cql");
    config.setProperty("clusterConfiguration.serializer.config.ioRegistries", "org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry");

When I call

GraphTraversalSource g = traversal().withRemote(config);

I get a traversal source and everything seems fine. However, to use the management stuff that Janus provides, I seem to need a JanusGraphManagement object. I cannot get the generic Graph object above and cast it to a JanusGraph. The docs suggest using a JanusGraphFactory: https://docs.janusgraph.org/basics/configuration/#janusgraphfactory

So I call

    JanusGraph janusGraph = JanusGraphFactory.open(config);

I get the following stack trace:

    Exception in thread "main" java.lang.IllegalArgumentException: Could not find implementation class: org.janusgraph.diskstorage.cql.CQLStoreManager
    at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:60)
    at org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:440)
    at org.janusgraph.diskstorage.Backend.getStorageManager(Backend.java:411)
    at org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder.build(GraphDatabaseConfigurationBuilder.java:50)
    at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:161)
    at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:132)
    at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:112)
    at com.activitystream.database.GraphMigration.migrateDatabase(GraphMigration.java:69)
    at com.activitystream.runners.persistence.DataStores.migrateDatabase(DataStores.java:27)
    at com.activitystream.runners.persistence.EntityPersistenceRunner.main(EntityPersistenceRunner.java:23)
    Caused by: java.lang.ClassNotFoundException: org.janusgraph.diskstorage.cql.CQLStoreManager
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:56)
    ... 9 more

Is it possible to modify the schema over a remote connection?

If it is not possible, how can one modify the schema?

Any insight would be appreciated.

1

1 Answers

5
votes

You basically have two choices - either:

  1. Interact with your JanusGraphManagement object by way of scripts sent to Gremlin Server (typically by way of a session but I guess you could package an entire "management script" together and submit it as one request) or
  2. Bypass Gremlin Server and instantiation your JanusGraphManagement object locally as directed in the JanusGraph documentation.

There is no way to have return a JanusGraphManagement to your client as it is not a serializable object that can be sent back from the server.