如何更改janusgraph客户端读取一致性?

soat7uwm  于 2021-06-10  发布在  Cassandra
关注(0)|答案(1)|浏览(574)

我对janusgraph很陌生,使用cassandra作为后端数据库。我有一个查询,它使用查找节点的所有传入边。为此,我需要在janusgraph配置中将读取一致性设置为1。我尝试了以下配置,但无法获得正确的读取一致性:

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;
}

然而,客户仍然显示cassandratransaction在仲裁级别上的一致性。
以下是日志:
16:40:54.799[main]调试o.j.d.cassandra.cassandratransaction-已创建cassandratransaction@25e2a451[read=quorum,write=quorum]16:40:54.800[main]调试o.j.d.cassandra.cassandratransaction-已创建cassandratransaction@1698ee84[读=法定人数,write=quorum]all edges=100000 16:40:55.754[main]调试o.j.g.database.standardjanusgraph-正在关闭图形standardjanusgraph[cassandrathrift:[10.70.1.167]]使用关闭钩子线程[thread-5,5,main]16:40:55.755[main]调试o.j.d.cassandra.cassandratransaction-已创建cassandratransaction@3e5499cc[读=法定人数,write=quorum]16:40:55.755[main]调试o.j.d.cassandra.cassandratransaction-已创建cassandratransaction@67ab1c47[read=quorum,write=quorum]16:40:56.113[main]调试o.j.d.cassandra.cassandratransaction-已创建cassandratransaction@6821ea29[读=法定人数,write=quorum]16:40:56.542[main]调试o.j.d.cassandra.cassandratransaction-已创建cassandratransaction@338494fa[read=quorum,write=quorum]16:40:56.909[main]信息o.j.d.c.t.cassandrathriftstoremanager-关闭的thrift连接池。
关于如何将此更改为一个或本地一致性级别有何建议??

i34xakig

i34xakig1#

首先,我会切换到通过cql连接,而不是节俭。thrift已经被弃用了,所以它没有看到任何缺陷修复改进的好处。换句话说,如果它本身就坏了,就不会被修复。所以你最好用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

其次,您需要确保一致地使用存储后端的配置属性。不幸的是janusgraph和cassandra很容易混淆。。。

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");

在上面的示例中,您已经将属性设置为 storage.cassandra (节俭)和 storage.cql (cql)配置。
如果仍然不起作用,请尝试添加此设置:

log.tx.key-consistent=true

将事务日志设置为密钥一致会覆盖它的默认值 QUORUM 一致性访问,如果这是显示为 QUORUM .

相关问题