0

我试着做

DseCluster dseCluster = null;

    try {
        dseCluster = DseCluster.builder()
                .addContactPoint("192.168.1.43")
                .build();
        DseSession dseSession = dseCluster.connect();
        GraphTraversalSource g = DseGraph.traversal(dseSession, new GraphOptions().setGraphName("graph"));
        GraphStatement graphStatement =  DseGraph.statementFromTraversal(g.addV("test"));
        GraphResultSet grs = dseSession.executeGraph(graphStatement.setGraphName("graph"));
        System.out.println(grs.one().asVertex());

        g.tx().commit();

    } finally {
        if (dseCluster != null) dseCluster.close();
    }

因为这是在被 Datastax 收购之前在 TitanDB 中允许的,但我得到“图形不支持事务”

Exception in thread "main" java.lang.UnsupportedOperationException: Graph does not support transactions
00:27:52.420 [cluster1-nio-worker-0] DEBUG io.netty.buffer.PoolThreadCache - Freed 26 thread-local buffer(s) from thread: cluster1-nio-worker-0
    at org.apache.tinkerpop.gremlin.structure.Graph$Exceptions.transactionsNotSupported(Graph.java:1127)
    at org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph.tx(EmptyGraph.java:75)
    at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.tx(GraphTraversalSource.java:320)
    at testbed.TestBed.main(TestBed.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

除了提到 Datastax DSE Graph 作为事务性之外,我在文档中找不到任何内容。

谢谢!

4

1 回答 1

2

迈克尔,在安迪回答的另一篇文章中,他提供了一些关于 DSE 目前如何“进行”交易的见解。我们不会将 Tinkerpop 交易 API 直接暴露给最终用户。事务当前是隐式的,每个执行语句调用都会触发 DSE Graph Server 中的 Tinkerpop 事务机制。这是一个快速而肮脏的 GitHub 示例,展示了事务如何与 DSE Graph 一起工作 - https://github.com/jlacefie/GraphTransactionExample

于 2016-12-20T02:41:11.787 回答