2

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

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

但是,客户端仍然在 QUORUM 级别的一致性中显示 CassandraTransaction。

以下是日志:

16:40:54.799 [main] 调试 ojdcassandra.CassandraTransaction - 创建 CassandraTransaction@25e2a451 [read=QUORUM,write=QUORUM] 16:40:54.800 [main] 调试 ojdcassandra.CassandraTransaction - 创建 CassandraTransaction@1698ee84[read=QUORUM,write= QUORUM] 所有边 = 100000 16:40:55.754 [main] DEBUG ojgdatabase.StandardJanusGraph - 使用关闭挂钩 Thread[Thread-5,5,main] 16:40:55.755 关闭图 standardjanusgraph[cassandrathrift:[10.70.1.167]] [main] 调试 ojdcassandra.CassandraTransaction - 创建 CassandraTransaction@3e5499cc[read=QUORUM,write=QUORUM] 16:40:55.755 [main] 调试 ojdcassandra.CassandraTransaction - 创建 CassandraTransaction@67ab1c47[read=QUORUM,write=QUORUM] 16:40 :56.113 [main] DEBUG ojdcassandra.CassandraTransaction - 创建 CassandraTransaction@6821ea29[read=QUORUM,write=QUORUM] 16:40:56.542 [main] 调试 ojdcassandra.CassandraTransaction - 创建 CassandraTransaction@338494fa[read=QUORUM,write=QUORUM] 16:40:56.909 [main] INFO ojdctCassandraThriftStoreManager - 关闭 Thrift 连接池。

关于如何将其更改为 ONE 或 LOCAL 一致性级别的任何建议?

4

1 回答 1

1

一方面,我会切换到通过 CQL 而不是 Thrift 进行连接。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(Thrift) 和storage.cql(CQL) 配置上设置了属性。

如果这仍然不起作用,请尝试添加此设置:

log.tx.key-consistent=true

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

于 2020-02-26T14:43:29.307 回答