public static void rollbackQuietly(TitanTransaction tx) { if (null == tx) return; try { tx.rollback(); } catch (Throwable t) { log.warn("Unable to rollback transaction", t); } } }
private int executeSerialTransaction(final TransactionJob job, int number) { final AtomicInteger txSuccess = new AtomicInteger(0); for (int i = 0; i < number; i++) { TitanTransaction tx = graph.newTransaction(); try { job.run(tx); tx.commit(); txSuccess.incrementAndGet(); } catch (Exception ex) { tx.rollback(); ex.printStackTrace(); } } return txSuccess.get(); }
public void run() { awaitAllThreadsReady(); TitanTransaction tx = graph.newTransaction(); try { job.run(tx); tx.commit(); txSuccess.incrementAndGet(); } catch (Exception ex) { ex.printStackTrace(); if (tx.isOpen()) tx.rollback(); } finally { finishLatch.countDown(); } }
@Override public void run() { TitanTransaction tx = graph.buildTransaction().enableBatchLoading().start(); try { for (Map.Entry<Long, Map<String, Object>> vprop : properties) { Vertex v = tx.getVertex(vprop.getKey()); for (Map.Entry<String, Object> prop : vprop.getValue().entrySet()) { v.property(VertexProperty.Cardinality.single, prop.getKey(), prop.getValue()); } } tx.commit(); } catch (Throwable e) { failures.incrementAndGet(); log.error("Encountered exception while trying to write properties: ", e); } finally { if (tx != null && tx.isOpen()) tx.rollback(); } } }
@Override public void run() { while (run.get()) { TitanTransaction tx = graph.newTransaction(); try { for (int i = 0; i < batchR; i++) { Set<Vertex> vs = new HashSet<Vertex>(); Iterable<TitanVertex> vertices = tx.query().has("k",random.nextInt(maxK)).has("q",random.nextInt(maxQ)).vertices(); for (TitanVertex v : vertices) { if (!vs.add(v)) { duplicates.incrementAndGet(); System.err.println("Duplicate vertex: " + v); } } } tx.commit(); } catch (Throwable e) { e.printStackTrace(); } finally { if (tx.isOpen()) tx.rollback(); } } } });
@Override public void run() { while (run.get()) { TitanTransaction tx = graph.newTransaction(); try { for (int i = 0; i < batchV; i++) { TitanVertex v = tx.addVertex(); v.property("k", random.nextInt(maxK)); v.property("q", random.nextInt(maxQ)); } tx.commit(); } catch (Throwable e) { e.printStackTrace(); } finally { if (tx.isOpen()) tx.rollback(); } } } });
private void failTransactionOnCommit(final TransactionJob job) { TitanTransaction tx = graph.newTransaction(); try { job.run(tx); tx.commit(); fail(); } catch (Exception e) { //e.printStackTrace(); } finally { if (tx.isOpen()) tx.rollback(); } }
((TitanTransaction)gview).rollback();
@Test public void testMemoryLeakage() { long memoryBaseline = 0; SummaryStatistics stats = new SummaryStatistics(); int numRuns = 25; for (int r = 0; r < numRuns; r++) { if (r == 1 || r == (numRuns - 1)) { memoryBaseline = MemoryAssess.getMemoryUse(); stats.addValue(memoryBaseline); //System.out.println("Memory before run "+(r+1)+": " + memoryBaseline / 1024 + " KB"); } for (int t = 0; t < 1000; t++) { graph.addVertex(); graph.tx().rollback(); TitanTransaction tx = graph.newTransaction(); tx.addVertex(); tx.rollback(); } if (r == 1 || r == (numRuns - 1)) { memoryBaseline = MemoryAssess.getMemoryUse(); stats.addValue(memoryBaseline); //System.out.println("Memory after run " + (r + 1) + ": " + memoryBaseline / 1024 + " KB"); } clopen(); } System.out.println("Average: " + stats.getMean() + " Std. Dev: " + stats.getStandardDeviation()); assertTrue(stats.getStandardDeviation() < stats.getMin()); }
@Test public void testTransactionConfiguration() { // Superficial tests for a few transaction builder methods // Test read-only transaction TitanTransaction readOnlyTx = graph.buildTransaction().readOnly().start(); try { readOnlyTx.addVertex(); readOnlyTx.commit(); fail("Read-only transactions should not be able to add a vertex and commit"); } catch (Throwable t) { if (readOnlyTx.isOpen()) readOnlyTx.rollback(); } // Test custom log identifier String logID = "spam"; StandardTitanTx customLogIDTx = (StandardTitanTx) graph.buildTransaction().logIdentifier(logID).start(); assertEquals(logID, customLogIDTx.getConfiguration().getLogIdentifier()); customLogIDTx.rollback(); // Test timestamp Instant customTimestamp = Instant.ofEpochMilli(-42L); StandardTitanTx customTimeTx = (StandardTitanTx) graph.buildTransaction().commitTime(customTimestamp).start(); assertTrue(customTimeTx.getConfiguration().hasCommitTime()); assertEquals(customTimestamp, customTimeTx.getConfiguration().getCommitTime()); customTimeTx.rollback(); }
} catch (IllegalStateException e) { tx1.rollback(); try { v11.property(VertexProperty.Cardinality.single, "test", 5);
public static void rollbackQuietly(TitanTransaction tx) { if (null == tx) return; try { tx.rollback(); } catch (Throwable t) { log.warn("Unable to rollback transaction", t); } } }
public static void rollbackQuietly(TitanTransaction tx) { if (null == tx) return; try { tx.rollback(); } catch (Throwable t) { log.warn("Unable to rollback transaction", t); } } }
@Override public void rollback() { TitanTransaction tx = txs.get(); if (tx != null && tx.isOpen()) { try { tx.rollback(); } finally { txs.remove(); openTx.remove(tx); log.debug("Rolled back thread-bound transaction {}", tx); } } }
private int executeSerialTransaction(final TransactionJob job, int number) { final AtomicInteger txSuccess = new AtomicInteger(0); for (int i = 0; i < number; i++) { TitanTransaction tx = graph.newTransaction(); try { job.run(tx); tx.commit(); txSuccess.incrementAndGet(); } catch (Exception ex) { tx.rollback(); ex.printStackTrace(); } } return txSuccess.get(); }
public void run() { awaitAllThreadsReady(); TitanTransaction tx = graph.newTransaction(); try { job.run(tx); tx.commit(); txSuccess.incrementAndGet(); } catch (Exception ex) { ex.printStackTrace(); if (tx.isOpen()) tx.rollback(); } finally { finishLatch.countDown(); } }
private void failTransactionOnCommit(final TransactionJob job) { TitanTransaction tx = graph.newTransaction(); try { job.run(tx); tx.commit(); fail(); } catch (Exception e) { //e.printStackTrace(); } finally { if (tx.isOpen()) tx.rollback(); } }