use of org.neo4j.graphdb.TransactionFailureException in project neo4j-mobile-android by neo4j-contrib.
the class PersistenceManager method delistResourcesForTransaction.
void delistResourcesForTransaction() throws NotInTransactionException {
Transaction tx = this.getCurrentTransaction();
if (tx == null) {
throw new NotInTransactionException();
}
NeoStoreTransaction con = txConnectionMap.get(tx);
if (con != null) {
try {
tx.delistResource(con.getXAResource(), XAResource.TMSUCCESS);
} catch (SystemException e) {
throw new TransactionFailureException("Failed to delist resource '" + con + "' from current transaction.", e);
}
}
}
use of org.neo4j.graphdb.TransactionFailureException 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 org.neo4j.graphdb.TransactionFailureException in project neo4j-mobile-android by neo4j-contrib.
the class DefaultRelationshipTypeCreator method getOrCreate.
public int getOrCreate(TransactionManager txManager, EntityIdGenerator idGenerator, PersistenceManager persistence, RelationshipTypeHolder relTypeHolder, String name) {
RelTypeCreater createrThread = new RelTypeCreater(name, txManager, idGenerator, persistence);
synchronized (createrThread) {
createrThread.start();
while (createrThread.isAlive()) {
try {
createrThread.wait(50);
} catch (InterruptedException e) {
Thread.interrupted();
}
}
}
if (createrThread.succeded()) {
int id = createrThread.getRelTypeId();
relTypeHolder.addRawRelationshipType(new RelationshipTypeData(id, name));
return id;
}
throw new TransactionFailureException("Unable to create relationship type " + name);
}
use of org.neo4j.graphdb.TransactionFailureException in project neo4j-mobile-android by neo4j-contrib.
the class LockReleaser method releaseCows.
void releaseCows(Transaction cowTxId, int param) {
PrimitiveElement element = cowMap.remove(cowTxId);
if (element == null) {
return;
}
ArrayMap<Long, CowNodeElement> cowNodeElements = element.nodes;
Set<Entry<Long, CowNodeElement>> nodeEntrySet = cowNodeElements.entrySet();
for (Entry<Long, CowNodeElement> entry : nodeEntrySet) {
NodeImpl node = nodeManager.getNodeIfCached(entry.getKey());
if (node != null) {
CowNodeElement nodeElement = entry.getValue();
if (param == Status.STATUS_COMMITTED) {
node.commitRelationshipMaps(nodeElement.relationshipAddMap, nodeElement.relationshipRemoveMap);
node.commitPropertyMaps(nodeElement.propertyAddMap, nodeElement.propertyRemoveMap);
} else if (param != Status.STATUS_ROLLEDBACK) {
throw new TransactionFailureException("Unknown transaction status: " + param);
}
}
}
ArrayMap<Long, CowRelElement> cowRelElements = element.relationships;
Set<Entry<Long, CowRelElement>> relEntrySet = cowRelElements.entrySet();
for (Entry<Long, CowRelElement> entry : relEntrySet) {
RelationshipImpl rel = nodeManager.getRelIfCached(entry.getKey());
if (rel != null) {
CowRelElement relElement = entry.getValue();
if (param == Status.STATUS_COMMITTED) {
rel.commitPropertyMaps(relElement.propertyAddMap, relElement.propertyRemoveMap);
} else if (param != Status.STATUS_ROLLEDBACK) {
throw new TransactionFailureException("Unknown transaction status: " + param);
}
}
}
cowMap.remove(cowTxId);
}
use of org.neo4j.graphdb.TransactionFailureException in project graphdb by neo4j-attic.
the class TestUpgradeStore method makeSureStoreCantBeUpgradedIfNotExplicitlyToldTo.
@Test
public void makeSureStoreCantBeUpgradedIfNotExplicitlyToldTo() throws Exception {
String path = path(11);
new EmbeddedGraphDatabase(path).shutdown();
setOlderNeoStoreVersion(path);
try {
new EmbeddedGraphDatabase(path);
fail("Shouldn't be able to upgrade if not told to");
} catch (TransactionFailureException e) {
if (!(e.getCause() instanceof IllegalStoreVersionException)) {
throw e;
}
}
}
Aggregations