cassandragremlinjanusgraphgremlin-serverjanus

How to identify the configured keyspace using JanusGraph APIs?


While going through https://docs.janusgraph.org/v0.5/basics/configuration-reference/ , I found that for key storage.cassandra.keyspace,

The name of JanusGraph's keyspace. It will be created if it does not exist. If it is not supplied, but graph.graphname is, then the the keyspace will be set to that.

I want to get this configured keyspace at runtime in java code for some validation. Is there any way through which we can identify this configured keyspace?

Also, if we create keyspace through Cassandra CQL command and try to use that in JanusGraph server, server throws exception. This means that JanusGraph can nly recognize keyspace which is created by JanusGraph itself. So, I want to identify that which keyspace is created by JanusGraph and which by Cassandra itself.


Solution

  • If you don't specify storage.cassandra.keyspace, the JanusGraph server will use the value of graph.graphname as it says in the docs you linked (from CQLStoreManager.java):

        private String determineKeyspaceName(Configuration config) {
            if ((!config.has(KEYSPACE) && (config.has(GRAPH_NAME)))) return config.get(GRAPH_NAME);
            return config.get(KEYSPACE);
        }
    

    And if graphname isn't configured, the JanusGraph server by default will create a keyspace named janusgraph if it doesn't already exist.

    Note that if you create the keyspace yourself, you must create the JanusGraph tables using the schema provided in conf/cassandra/cassandraTables.cql. Otherwise, JanusGraph will think the keyspace is invalid and will throw an error. Cheers!