本文整理了Java中org.apache.tinkerpop.gremlin.structure.Transaction.addTransactionListener()
方法的一些代码示例,展示了Transaction.addTransactionListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.addTransactionListener()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Transaction
类名称:Transaction
方法名:addTransactionListener
[英]Adds a listener that is called back with a status when a commit or rollback is successful. It is expected that listeners be bound to the current thread as is standard for transactions. Therefore a listener registered in the current thread will not get callback events from a commit or rollback call in a different thread.
[中]添加一个侦听器,当提交或回滚成功时,该侦听器将以状态被回调。作为事务的标准,侦听器应该绑定到当前线程。因此,在当前线程中注册的侦听器不会从其他线程中的提交或回滚调用中获取回调事件。
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldNotifyTransactionListenersInSameThreadOnlyOnCommitSuccess() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
g.tx().addTransactionListener(s -> {
if (s == Transaction.Status.COMMIT) count.incrementAndGet();
});
final Thread t = new Thread(() -> g.tx().commit());
t.start();
t.join();
assertEquals(0, count.get());
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldNotifyTransactionListenersInSameThreadOnlyOnRollbackSuccess() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
g.tx().addTransactionListener(s -> {
if (s == Transaction.Status.ROLLBACK) count.incrementAndGet();
});
final Thread t = new Thread(() -> g.tx().rollback());
t.start();
t.join();
assertEquals(0, count.get());
}
代码示例来源:origin: apache/tinkerpop
public TransactionalEventQueue(final Graph graph) {
if (!graph.features().graph().supportsTransactions())
throw new IllegalStateException(String.format("%s requires the graph to support transactions", EventStrategy.class.getName()));
// since this is a transactional graph events are enqueued so the events should be fired/reset only after
// transaction is committed/rolled back as tied to a graph transaction
graph.tx().addTransactionListener(status -> {
if (status == Transaction.Status.COMMIT)
fireEventQueue();
else if (status == Transaction.Status.ROLLBACK)
resetEventQueue();
else
throw new RuntimeException(String.format("The %s is not aware of this status: %s", EventQueue.class.getName(), status));
});
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldNotifyTransactionListenersOnRollbackSuccess() {
final AtomicInteger count = new AtomicInteger(0);
g.tx().addTransactionListener(s -> {
if (s == Transaction.Status.ROLLBACK) count.incrementAndGet();
});
g.tx().rollback();
assertEquals(1, count.get());
}
代码示例来源:origin: apache/tinkerpop
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldNotifyTransactionListenersOnCommitSuccess() {
final AtomicInteger count = new AtomicInteger(0);
g.tx().addTransactionListener(s -> {
if (s == Transaction.Status.COMMIT) count.incrementAndGet();
});
g.tx().commit();
assertEquals(1, count.get());
}
代码示例来源:origin: com.syncleus.ferma/ferma
@Override
public void addTransactionListener(final Consumer<Transaction.Status> listener) {
this.getDelegate().addTransactionListener(listener);
}
代码示例来源:origin: Syncleus/Ferma
@Override
public void addTransactionListener(final Consumer<Transaction.Status> listener) {
this.getDelegate().addTransactionListener(listener);
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldNotifyTransactionListenersInSameThreadOnlyOnRollbackSuccess() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
g.tx().addTransactionListener(s -> {
if (s == Transaction.Status.ROLLBACK) count.incrementAndGet();
});
final Thread t = new Thread(() -> g.tx().rollback());
t.start();
t.join();
assertEquals(0, count.get());
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldNotifyTransactionListenersInSameThreadOnlyOnCommitSuccess() throws Exception {
final AtomicInteger count = new AtomicInteger(0);
g.tx().addTransactionListener(s -> {
if (s == Transaction.Status.COMMIT) count.incrementAndGet();
});
final Thread t = new Thread(() -> g.tx().commit());
t.start();
t.join();
assertEquals(0, count.get());
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
public TransactionalEventQueue(final Graph graph) {
if (!graph.features().graph().supportsTransactions())
throw new IllegalStateException(String.format("%s requires the graph to support transactions", EventStrategy.class.getName()));
// since this is a transactional graph events are enqueued so the events should be fired/reset only after
// transaction is committed/rolled back as tied to a graph transaction
graph.tx().addTransactionListener(status -> {
if (status == Transaction.Status.COMMIT)
fireEventQueue();
else if (status == Transaction.Status.ROLLBACK)
resetEventQueue();
else
throw new RuntimeException(String.format("The %s is not aware of this status: %s", EventQueue.class.getName(), status));
});
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldNotifyTransactionListenersOnCommitSuccess() {
final AtomicInteger count = new AtomicInteger(0);
g.tx().addTransactionListener(s -> {
if (s == Transaction.Status.COMMIT) count.incrementAndGet();
});
g.tx().commit();
assertEquals(1, count.get());
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
@Test
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_TRANSACTIONS)
public void shouldNotifyTransactionListenersOnRollbackSuccess() {
final AtomicInteger count = new AtomicInteger(0);
g.tx().addTransactionListener(s -> {
if (s == Transaction.Status.ROLLBACK) count.incrementAndGet();
});
g.tx().rollback();
assertEquals(1, count.get());
}
内容来源于网络,如有侵权,请联系作者删除!