KayV
KayV

Reputation: 13835

How to change Janusgraph Client read consistency?

I am new to Janusgraph and using Cassandra as the backend database. I have a query which uses find all incoming edges to a node. For that I need to make the read consistency to ONE in Janusgraph configuration. I have tried the following configuration but am not able to get the correct read consistency:

public static JanusGraph create() {
    JanusGraphFactory.Builder config = JanusGraphFactory.build();
    config.set("storage.backend", "cassandrathrift");
    config.set("storage.cassandra.keyspace", "cs_graph");
    config.set("storage.cassandra.read-consistency-level","ONE");
    config.set("storage.cassandra.write-consistency-level","ONE");
    config.set("storage.cassandra.frame-size-mb", "128");
    config.set("storage.cassandra.thrift.cpool.max-wait", 360000);
    config.set("storage.hostname", "10.XXX.1.XXX");
    config.set("connectionPool.keepAliveInterval","360000");
    config.set("storage.cql.only-use-local-consistency-for-system-operations","true");

    graph = config.open();
    System.out.println("Graph = "+graph);
    traversalSource = graph.traversal();
    System.out.println("traversalSource = "+traversalSource);
    getAllEdges();
    return graph;
}

However, the client is still showing the CassandraTransaction in QUORUM level of consistency.

Here are the logs:

16:40:54.799 [main] DEBUG o.j.d.cassandra.CassandraTransaction - Created CassandraTransaction@25e2a451[read=QUORUM,write=QUORUM] 16:40:54.800 [main] DEBUG o.j.d.cassandra.CassandraTransaction - Created CassandraTransaction@1698ee84[read=QUORUM,write=QUORUM] All edges = 100000 16:40:55.754 [main] DEBUG o.j.g.database.StandardJanusGraph - Shutting down graph standardjanusgraph[cassandrathrift:[10.70.1.167]] using shutdown hook Thread[Thread-5,5,main] 16:40:55.755 [main] DEBUG o.j.d.cassandra.CassandraTransaction - Created CassandraTransaction@3e5499cc[read=QUORUM,write=QUORUM] 16:40:55.755 [main] DEBUG o.j.d.cassandra.CassandraTransaction - Created CassandraTransaction@67ab1c47[read=QUORUM,write=QUORUM] 16:40:56.113 [main] DEBUG o.j.d.cassandra.CassandraTransaction - Created CassandraTransaction@6821ea29[read=QUORUM,write=QUORUM] 16:40:56.542 [main] DEBUG o.j.d.cassandra.CassandraTransaction - Created CassandraTransaction@338494fa[read=QUORUM,write=QUORUM] 16:40:56.909 [main] INFO o.j.d.c.t.CassandraThriftStoreManager - Closed Thrift connection pooler.

Any suggestions on how to change this to ONE or LOCAL consistency level??

Upvotes: 2

Views: 400

Answers (1)

Aaron
Aaron

Reputation: 57748

For one, I would switch to connect over CQL instead of Thrift. Thrift has been deprecated, so it's not seeing the benefits of any improvements for bug fixes. In other words, if it's inherently broken, it won't be fixed. So you're much better off using CQL.

config.set("storage.backend", "cql");
config.set("storage.cql.keyspace", "cs_graph");
storage.cql.read-consistency-level=ONE
storage.cql.write-consistency-level=ONE

Secondly, you need to make sure that you're consistently using the config properties for your storage backend. Unfortunately with JanusGraph and Cassandra, these are easy to mix-up...

config.set("storage.cassandra.read-consistency-level","ONE");
config.set("storage.cassandra.write-consistency-level","ONE");
....
config.set("storage.cql.only-use-local-consistency-for-system-operations","true");

In the above example, you've set properties on storage.cassandra (Thrift) and the storage.cql (CQL) configs.

If that still doesn't work, try adding this setting as well:

log.tx.key-consistent=true

Setting the transaction log to be key-consistent overrides it's default QUORUM consistency access, if that's what is showing as QUORUM.

Upvotes: 1

Related Questions