本文整理了Java中org.apache.tinkerpop.gremlin.structure.Graph.tx()
方法的一些代码示例,展示了Graph.tx()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.tx()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Graph
类名称:Graph
方法名:tx
[英]Configure and control the transactions for those graphs that support this feature. Note that this method does not indicate the creation of a "transaction" object. A Transaction in the TinkerPop context is a transaction "factory" or "controller" that helps manage transactions owned by the underlying graph database.
[中]为支持此功能的图形配置和控制事务。请注意,此方法不指示创建“事务”对象。TinkerPop上下文中的事务是一个事务“工厂”或“控制器”,用于帮助管理底层图形数据库所拥有的事务。
代码示例来源:origin: JanusGraph/janusgraph
@Override
public void rollbackAll() {
graphs.forEach((key, graph) -> {
if (graph.tx().isOpen()) {
graph.tx().rollback();
}
});
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public void commitAll() {
graphs.forEach((key, graph) -> {
if (graph.tx().isOpen())
graph.tx().commit();
});
}
代码示例来源:origin: JanusGraph/janusgraph
public void closeTx(Graph graph, Boolean commit) {
if (graph.tx().isOpen()) {
if (commit) {
graph.tx().commit();
} else {
graph.tx().rollback();
}
}
}
代码示例来源:origin: thinkaurelius/titan
@Override
public void clear(Graph g, final Configuration configuration) throws Exception {
if (null != g) {
while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph();
TitanGraph graph = (TitanGraph) g;
if (graph.isOpen()) {
if (g.tx().isOpen()) g.tx().rollback();
g.close();
}
}
WriteConfiguration config = new CommonsConfiguration(configuration);
BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE);
if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) {
TitanGraphBaseTest.clearGraph(config);
}
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public void clear(Graph g, final Configuration configuration) throws Exception {
if (null != g) {
while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph();
JanusGraph graph = (JanusGraph) g;
if (graph.isOpen()) {
if (g.tx().isOpen()) g.tx().rollback();
try {
g.close();
} catch (IOException | IllegalStateException e) {
logger.warn("Titan graph may not have closed cleanly", e);
}
}
}
WriteConfiguration config = new CommonsConfiguration(configuration);
BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config,
BasicConfiguration.Restriction.NONE);
if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) {
JanusGraphBaseTest.clearGraph(config);
}
}
代码示例来源:origin: apache/tinkerpop
/**
* Proxies calls through to the underlying {@link Graph#tx()}.
*/
public Transaction tx() {
return this.graph.tx();
}
代码示例来源:origin: apache/tinkerpop
@Override
public void run() {
try {
latchCommitInOtherThread.await();
} catch (InterruptedException ie) {
throw new RuntimeException(ie);
}
// try to commit the other transaction
graph.tx().commit();
latchCommittedInOtherThread.countDown();
}
};
代码示例来源:origin: apache/tinkerpop
@Override
public Transaction tx() {
return this.starVertex.graph().tx();
}
代码示例来源:origin: apache/tinkerpop
/**
* Commit transactions across all {@link Graph} objects.
*/
public final void commitAll() {
graphs.entrySet().forEach(e -> {
final Graph graph = e.getValue();
if (graph.features().graph().supportsTransactions() && graph.tx().isOpen())
graph.tx().commit();
});
}
代码示例来源:origin: apache/tinkerpop
/**
* Rollback transactions across all {@link Graph} objects.
*/
public final void rollbackAll() {
graphs.entrySet().forEach(e -> {
final Graph graph = e.getValue();
if (graph.features().graph().supportsTransactions() && graph.tx().isOpen())
graph.tx().rollback();
});
}
代码示例来源:origin: hugegraph/hugegraph
public void commitAll() {
this.graphs.values().forEach(graph -> {
if (graph.features().graph().supportsTransactions() &&
graph.tx().isOpen()) {
graph.tx().commit();
}
});
}
代码示例来源:origin: hugegraph/hugegraph
public void rollbackAll() {
this.graphs.values().forEach(graph -> {
if (graph.features().graph().supportsTransactions() &&
graph.tx().isOpen()) {
graph.tx().rollback();
}
});
}
代码示例来源:origin: apache/tinkerpop
protected void onSideEffectSuccess(final Graph graph, final Context ctx) {
// there was no "writing" here, just side-effect retrieval, so if a transaction was opened then
// just close with rollback
if (graph.features().graph().supportsTransactions() && graph.tx().isOpen()) graph.tx().rollback();
}
代码示例来源:origin: apache/tinkerpop
/**
* Utility method that commits if the graph supports transactions and executes an assertion function before and
* after the commit. It assumes that the assertion should be true before and after the commit.
*/
public void tryCommit(final Graph graph, final Consumer<Graph> assertFunction) {
assertFunction.accept(graph);
if (graph.features().graph().supportsTransactions()) {
graph.tx().commit();
assertFunction.accept(graph);
}
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_THREADED_TRANSACTIONS)
public void shouldOpenTxWhenThreadedTransactionIsCreated() throws Exception {
// threaded transactions should be immediately open on creation
final Graph threadedG = g.tx().createThreadedTx();
assertThat(threadedG.tx().isOpen(), is(true));
threadedG.tx().rollback();
assertThat(threadedG.tx().isOpen(), is(false));
}
代码示例来源:origin: apache/tinkerpop
/**
* Utility method that commits if the graph supports transactions.
*/
public void tryCommit(final Graph graph) {
if (graph.features().graph().supportsTransactions())
graph.tx().commit();
}
代码示例来源:origin: apache/tinkerpop
/**
* Utility method that rollsback if the graph supports transactions.
*/
public void tryRollback(final Graph graph) {
if (graph.features().graph().supportsTransactions())
graph.tx().rollback();
}
代码示例来源:origin: apache/tinkerpop
@Override
public void execute(final Vertex sourceVertex, final Messenger<Tuple> messenger, final Memory memory) {
try {
executeInternal(sourceVertex, messenger, memory);
} catch (Exception e) {
if (graph.features().graph().supportsTransactions()) {
graph.tx().rollback();
}
throw e;
}
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = FEATURE_TRANSACTIONS)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = FEATURE_THREADED_TRANSACTIONS, supported = false)
public void shouldThrowOnThreadedTransactionNotSupported() {
try {
graph.tx().createThreadedTx();
fail("An exception should be thrown since the threaded transaction feature is not supported");
} catch (Exception e) {
validateException(Transaction.Exceptions.threadedTransactionsNotSupported(), e);
}
}
}
代码示例来源:origin: JanusGraph/janusgraph
final Vertex john = g.addV().property("name", "John").property("age", 3).property("length", 110).next();
final Vertex mike = g.addV().property("name", "Mike").property("age", 4).property("length", 130).next();
aGraph.tx().commit();
内容来源于网络,如有侵权,请联系作者删除!