use of javax.transaction.TransactionManager in project graphdb by neo4j-attic.
the class MasterImpl method suspendOtherAndResumeThis.
Transaction suspendOtherAndResumeThis(SlaveContext txId) {
try {
TransactionManager txManager = graphDbConfig.getTxModule().getTxManager();
Transaction otherTx = txManager.getTransaction();
Transaction transaction = getTx(txId);
if (otherTx != null && otherTx == transaction) {
return null;
} else {
if (otherTx != null) {
txManager.suspend();
}
if (transaction == null) {
beginTx(txId);
} else {
txManager.resume(transaction);
}
return otherTx;
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of javax.transaction.TransactionManager in project graphdb by neo4j-attic.
the class MasterImpl method beginTx.
private Transaction beginTx(SlaveContext txId) {
try {
TransactionManager txManager = graphDbConfig.getTxModule().getTxManager();
txManager.begin();
Transaction tx = txManager.getTransaction();
transactions.put(txId, tx);
return tx;
} catch (NotSupportedException e) {
throw new RuntimeException(e);
} catch (SystemException e) {
throw new RuntimeException(e);
}
}
use of javax.transaction.TransactionManager in project graphdb by neo4j-attic.
the class MasterImpl method suspendThisAndResumeOther.
void suspendThisAndResumeOther(Transaction otherTx, SlaveContext txId) {
try {
TransactionManager txManager = graphDbConfig.getTxModule().getTxManager();
txManager.suspend();
if (otherTx != null) {
txManager.resume(otherTx);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of javax.transaction.TransactionManager in project neo4j-mobile-android by neo4j-contrib.
the class EmbeddedGraphDbImpl method beginTx.
/**
* @throws TransactionFailureException if unable to start transaction
*/
public Transaction beginTx() {
if (graphDbInstance.transactionRunning()) {
if (placeboTransaction == null) {
placeboTransaction = new PlaceboTransaction(graphDbInstance.getTransactionManager());
}
return placeboTransaction;
}
TransactionManager txManager = graphDbInstance.getTransactionManager();
Transaction result = null;
try {
txManager.begin();
result = new TopLevelTransaction(txManager, txManager.getTransaction());
} catch (Exception e) {
throw new TransactionFailureException("Unable to begin transaction", e);
}
return result;
}
use of javax.transaction.TransactionManager in project graphdb by neo4j-attic.
the class TestNeo4jCacheAndPersistence method testTxCacheLoadIsolation.
@Test
public void testTxCacheLoadIsolation() throws Exception {
Node node = getGraphDb().createNode();
node.setProperty("someproptest", "testing");
Node node1 = getGraphDb().createNode();
node1.setProperty("someotherproptest", 2);
commit();
EmbeddedGraphDatabase graphDb = (EmbeddedGraphDatabase) getGraphDb();
TransactionManager txManager = graphDb.getConfig().getTxModule().getTxManager();
NodeManager nodeManager = graphDb.getConfig().getGraphDbModule().getNodeManager();
txManager.begin();
node.setProperty("someotherproptest", "testing2");
Relationship rel = node.createRelationshipTo(node1, MyRelTypes.TEST);
javax.transaction.Transaction txA = txManager.suspend();
txManager.begin();
assertEquals("testing", node.getProperty("someproptest"));
assertTrue(!node.hasProperty("someotherproptest"));
assertTrue(!node.hasRelationship());
nodeManager.clearCache();
assertEquals("testing", node.getProperty("someproptest"));
assertTrue(!node.hasProperty("someotherproptest"));
javax.transaction.Transaction txB = txManager.suspend();
txManager.resume(txA);
assertEquals("testing", node.getProperty("someproptest"));
assertTrue(node.hasProperty("someotherproptest"));
assertTrue(node.hasRelationship());
nodeManager.clearCache();
assertEquals("testing", node.getProperty("someproptest"));
assertTrue(node.hasProperty("someotherproptest"));
assertTrue(node.hasRelationship());
txManager.suspend();
txManager.resume(txB);
assertEquals("testing", node.getProperty("someproptest"));
assertTrue(!node.hasProperty("someotherproptest"));
assertTrue(!node.hasRelationship());
txManager.rollback();
txManager.resume(txA);
node.delete();
node1.delete();
rel.delete();
txManager.commit();
newTransaction();
}
Aggregations