Java Code Examples for org.apache.tinkerpop.gremlin.structure.Transaction#Status
The following examples show how to use
org.apache.tinkerpop.gremlin.structure.Transaction#Status .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphManager.java From hugegraph with Apache License 2.0 | 6 votes |
private void closeTx(final Set<String> graphSourceNamesToCloseTxOn, final Transaction.Status tx) { final Set<Graph> graphsToCloseTxOn = new HashSet<>(); graphSourceNamesToCloseTxOn.forEach(name -> { if (this.graphs.containsKey(name)) { graphsToCloseTxOn.add(this.graphs.get(name)); } }); graphsToCloseTxOn.forEach(graph -> { if (graph.features().graph().supportsTransactions() && graph.tx().isOpen()) { if (tx == Transaction.Status.COMMIT) { graph.tx().commit(); } else { graph.tx().rollback(); } } }); }
Example 2
Source File: DefaultGraphManager.java From tinkerpop with Apache License 2.0 | 6 votes |
/** * Selectively close transactions on the specified graphs or the graphs of traversal sources. */ private void closeTx(final Set<String> graphSourceNamesToCloseTxOn, final Transaction.Status tx) { final Set<Graph> graphsToCloseTxOn = new HashSet<>(); // by the time this method has been called, it should be validated that the source/graph is present. // might be possible that it could have been removed dynamically, but that i'm not sure how one would do // that as of right now unless they were embedded in which case they'd need to know what they were doing // anyway graphSourceNamesToCloseTxOn.forEach(r -> { if (graphs.containsKey(r)) graphsToCloseTxOn.add(graphs.get(r)); else graphsToCloseTxOn.add(traversalSources.get(r).getGraph()); }); graphsToCloseTxOn.forEach(graph -> { if (graph.features().graph().supportsTransactions() && graph.tx().isOpen()) { if (tx == Transaction.Status.COMMIT) graph.tx().commit(); else graph.tx().rollback(); } }); }
Example 3
Source File: BitsyTransactionContext.java From bitsy with Apache License 2.0 | 5 votes |
public BitsyTransactionContext(IGraphStore store) { this.unmodifiedVertices = new HashMap<UUID, BitsyVertex>(); this.unmodifiedEdges = new HashMap<UUID, BitsyEdge>(); this.changedVertices = new HashMap<UUID, BitsyVertex>(); this.changedEdges = new HashMap<UUID, BitsyEdge>(); this.store = store; this.transactionListeners = new ArrayList<Consumer<Transaction.Status>>(); this.adjMap = new AdjacencyMap(false, new IEdgeRemover() { @Override public IEdge removeEdge(UUID id) { return removeEdgeOnVertexDelete(id); } }); }
Example 4
Source File: DelegatingTransactionTest.java From Ferma with Apache License 2.0 | 5 votes |
@Test public void testAddTxListener() { Consumer<Transaction.Status> txListener = Mockito.mock(Consumer.class, "Foo"); delegatingTx.addTransactionListener(txListener); // Only delegating so the same listener should be passed Mockito.verify(gremlinTx, Mockito.times(1)).addTransactionListener(txListener); Mockito.verifyZeroInteractions(framedGraph); Mockito.verifyZeroInteractions(txListener); Mockito.verifyNoMoreInteractions(gremlinTx); }
Example 5
Source File: DelegatingTransactionTest.java From Ferma with Apache License 2.0 | 5 votes |
@Test public void testRemoveTxListener() { Consumer<Transaction.Status> txListener = Mockito.mock(Consumer.class, "Foo"); delegatingTx.removeTransactionListener(txListener); Mockito.verify(gremlinTx, Mockito.times(1)).removeTransactionListener(txListener); Mockito.verifyZeroInteractions(framedGraph, txListener); Mockito.verifyNoMoreInteractions(gremlinTx); }
Example 6
Source File: AbstractThreadLocalTransaction.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override protected List<Consumer<Transaction.Status>> initialValue() { return new ArrayList<>(); }
Example 7
Source File: DelegatingTransaction.java From Ferma with Apache License 2.0 | 4 votes |
@Override public void addTransactionListener(final Consumer<Transaction.Status> listener) { this.getDelegate().addTransactionListener(listener); }
Example 8
Source File: DelegatingTransaction.java From Ferma with Apache License 2.0 | 4 votes |
@Override public void removeTransactionListener(final Consumer<Transaction.Status> listener) { this.getDelegate().removeTransactionListener(listener); }