如何在 Datastax DSE 5.0 Graph 中提交和回滚图形操作?
How to commit and rollback graph operations in Datastax DSE 5.0 Graph?
我试过了
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();
}
因为在 TitanDB 被 Datastax 收购之前这是允许的,但我得到 "Graph does not support transactions"
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 是事务性的之外,我在文档中找不到任何内容。
谢谢!
Michail,在 Andy 回答的另一个 post 中,他提供了一些关于 DSE "does" 目前交易方式的见解。我们不会直接向最终用户公开 Tinkerpop 交易 API。事务目前是隐式的,每个 executestatement 调用都会触发 DSE Graph Server 中的 Tinkerpop 事务机制。这是一个快速而肮脏的 GitHub 示例,展示了交易如何与 DSE Graph 一起工作 - https://github.com/jlacefie/GraphTransactionExample
我试过了
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();
}
因为在 TitanDB 被 Datastax 收购之前这是允许的,但我得到 "Graph does not support transactions"
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 是事务性的之外,我在文档中找不到任何内容。
谢谢!
Michail,在 Andy 回答的另一个 post 中,他提供了一些关于 DSE "does" 目前交易方式的见解。我们不会直接向最终用户公开 Tinkerpop 交易 API。事务目前是隐式的,每个 executestatement 调用都会触发 DSE Graph Server 中的 Tinkerpop 事务机制。这是一个快速而肮脏的 GitHub 示例,展示了交易如何与 DSE Graph 一起工作 - https://github.com/jlacefie/GraphTransactionExample