public void abort() { try { checkCurrentTransaction(); currentTransaction.rollback(); } finally { currentTransaction = null; } }
@Override public void rollback() { host.releaseTransactionInfo(transactionInfo); boolean alive = transactionInfo.alive.getAndSet(false); if ( alive == true ) { realTransaction.rollback(); logger.trace("rolled back transaction {}", realTransaction.getTransactionId()); } } };
public boolean completeTransaction(TransactionInfo transactionInfo) { boolean completed = false; try { if ( transactionInfo.alive.get() == true && transactionInfo.inProcess.get() <= 0 && transactionInfo.written.get() == true ) { if ( transactionInfo.throwable.get() != null ) { transactionInfo.transaction.rollback(); sendThrowableToListeners(transactionInfo.throwable.get(), "Failure during transaction: {}", transactionInfo.batches); } else { transactionInfo.transaction.commit(); sendSuccessToListeners(transactionInfo.batches); } completed = true; } } catch (Throwable t) { transactionInfo.throwable.set(t); sendThrowableToListeners(t, "Failure to complete transaction: {}", transactionInfo.batches); } return completed; }
@Override public void run() { Transaction t2 = writeclient.openTransaction(); try { System.out.println("In ExecuteAskSecondThreadFalse run method"); SPARQLQueryManager sparqlQmgrTh = writeclient.newSPARQLQueryManager(); StringBuffer sparqlQueryTh = new StringBuffer(); sparqlQueryTh.append("ASK FROM <rdfxml> where { <http://example.org/kennedy/person1> <http://purl.org/dc/elements/1.1/title> \"Person\'s title\"@en }"); SPARQLQueryDefinition qdefTh = sparqlQmgrTh.newQueryDefinition(sparqlQueryTh.toString()); // Verify result in t2 transaction. boolean bAskInTransT2 = sparqlQmgrTh.executeAsk(qdefTh, t2); System.out.println("Method ExecuteAskSecondThreadFalse Run result is " + bAskInTransT2); assertFalse("Class ExecuteAskSecondThreadFalse Run result is incorrect. No Records should be returned.", bAskInTransT2); setbCompleted(true); } catch (ForbiddenUserException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FailedRequestException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (t2 != null) { t2.rollback(); t2 = null; } } } }
t2.rollback(); t2 = null;
@Test public void testMergeAs_jsonxml_Trx_FileHandle() throws Exception { Transaction trx = writerClient.openTransaction(); GraphManager gmWriter = writerClient.newGraphManager(); gmWriter.setDefaultMimetype(RDFMimeTypes.RDFJSON); File file = new File(datasource + "bug25348.json"); FileInputStream fis = new FileInputStream(file); Object graphData = convertInputStreamToString(fis); fis.close(); gmWriter.writeAs("htp://test.sem.graph/jsonMergeAsTrx", graphData, trx); File file2 = new File(datasource + "relative6.json"); Object graphData2 = convertFileToString(file2); gmWriter.mergeAs("htp://test.sem.graph/jsonMergeAsTrx", graphData2, trx); File readFile = gmWriter.readAs("htp://test.sem.graph/jsonMergeAsTrx", File.class, trx); String expectedContent = convertFileToString(readFile); assertTrue("Did not insert document or inserted empty doc", expectedContent.contains("http://example.com/ns/person#firstName") && expectedContent.contains("Anna's Homepage")); try { trx.commit(); trx = null; } catch (Exception e) { System.out.println(e); } finally { if (trx != null) { trx.rollback(); trx = null; } } }
@Test public void issue_357() { // open transaction Transaction transaction = Common.client.openTransaction(); try { // insert some data under transaction String insertString="BASE <http://example.org/addressbook>\n " + "INSERT DATA { <http://example.org/id#3333> <#email> \"jonny@ramone.com\"}"; SPARQLQueryDefinition insertDef = smgr.newQueryDefinition(insertString); smgr.executeUpdate(insertDef, transaction); // ask for it w/ transaction String queryString = "ASK WHERE { <http://example.org/id#3333> <http://example.org/addressbook#email> ?o }"; SPARQLQueryDefinition booleanDef = smgr.newQueryDefinition(queryString); assertTrue(smgr.executeAsk(booleanDef,transaction)); } finally { transaction.rollback(); } }
transPatch.rollback();
@Test public void testWrite_triplexml_FileHandle() throws Exception { Transaction trx = writerClient.openTransaction(); GraphManager gmWriter = writerClient.newGraphManager(); File file = new File(datasource + "relative5.xml"); FileHandle filehandle = new FileHandle(); filehandle.set(file); // Write Graph using transaction gmWriter.write("htp://test.sem.graph/tripxml", filehandle.withMimetype(RDFMimeTypes.TRIPLEXML), trx); // Validate graph written to DB by reading within the same transaction StringHandle handle = gmWriter.read("htp://test.sem.graph/tripxml", new StringHandle().withMimetype(RDFMimeTypes.TRIPLEXML), trx); assertTrue("Did not insert document or inserted empty doc", handle.toString().contains("Anna's Homepage")); // Delete Graph in the same transaction gmWriter.delete("htp://test.sem.graph/tripxml", trx); // Validate Graph is deleted try { gmWriter.read("htp://test.sem.graph/tripxml", new StringHandle(), trx); trx.commit(); trx = null; } catch (ResourceNotFoundException e) { System.out.println(e); } finally { if (trx != null) { trx.rollback(); trx = null; } } }
} finally { if (trx != null) { trx.rollback(); trx = null;
} finally { if (tstatus) { t1.rollback();
} finally { if (tstatus) { t1.rollback(); client2.release();
transaction2.rollback();
transaction2.rollback();
Transaction t2 = client.openTransaction(); xmlDocMgr1.patch(docId2, xmlPatch2, t2); t2.rollback(); waitForPropertyPropagate();
@Test public void test0POJOWriteWithTransaction() throws KeyManagementException, NoSuchAlgorithmException, Exception { PojoRepository<Artifact, Long> products = client.newPojoRepository(Artifact.class, Long.class); Transaction t = client.openTransaction(); // Load more than 100 objects try { for (int i = 1; i < 112; i++) { products.write(this.getArtifact(i), t); } assertEquals("Total number of object recods", 111, products.count(t)); for (long i = 1; i < 112; i++) { assertTrue("Product id " + i + " does not exist", products.exists(i, t)); this.validateArtifact(products.read(i, t)); } } catch (Exception e) { throw e; } finally { t.rollback(); } for (long i = 1; i < 112; i++) { assertFalse("Product id exists ?", products.exists(i)); } }
@Test public void testRollback() { String docId1 = "/test/testExists1.txt"; String docId2 = "/test/testExists2.txt"; TextDocumentManager docMgr = Common.client.newTextDocumentManager(); docMgr.write(docId1,new StringHandle().with("A simple text document")); Transaction transaction = Common.client.openTransaction(); StringHandle docHandle = docMgr.read(docId1, new StringHandle(), transaction); docMgr.write(docId2, docHandle, transaction); docMgr.delete(docId1, transaction); transaction.rollback(); assertTrue("Document 1 doesn't exist", docMgr.exists(docId1)!=null); assertTrue("Document 2 exists", docMgr.exists(docId2)==null); docMgr.delete(docId1); }
throw exp; } finally { transaction.rollback();
throw exp; } finally { transaction.rollback();