Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

all code now uses commit()/rollback() and stopTransaction() implement…

…ations simply call commit() or rollback().
  • Loading branch information...
commit 1c3404fac82d925fe24a41b0c6519181809b29eb 1 parent 0dd97e1
@okram okram authored
View
1  CHANGELOG.textile
@@ -19,6 +19,7 @@ h3. Version 2.3.0 (NOT OFFICIALLY RELEASED YET)
* Bumped to support Neo4j 1.9.M03
* Improved transaction concurrency in @DexGraph@
* Deprecated @stopTransaction()@ in favor of @commit()@ and @rollback()@
+* Loosed restrictions on edge-indexing in @GraphSail@ (though for some types of queries, exception thrown)
==<hr/>==
View
11 blueprints-core/src/main/java/com/tinkerpop/blueprints/util/wrappers/batch/BatchGraph.java
@@ -249,12 +249,11 @@ private void nextElement() {
* @param conclusion whether or not the current transaction was successful
*/
@Override
- public void stopTransaction(final Conclusion conclusion) {
- if (conclusion != Conclusion.SUCCESS) throw new IllegalArgumentException("Cannot abort batch loading");
- currentEdge = null;
- currentEdgeCached = null;
- remainingBufferSize = 0;
- baseGraph.commit();
+ public void stopTransaction(Conclusion conclusion) {
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
public void commit() {
View
7 ...ts-core/src/main/java/com/tinkerpop/blueprints/util/wrappers/batch/WritethroughGraph.java
@@ -39,8 +39,11 @@
* @param conclusion whether or not the current transaction was successful or not
*/
@Override
- public void stopTransaction(final Conclusion conclusion) {
- if (conclusion == Conclusion.FAILURE) throw new IllegalArgumentException("Failure not accepted");
+ public void stopTransaction(Conclusion conclusion) {
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
public void rollback() {
View
26 ...e/src/main/java/com/tinkerpop/blueprints/util/wrappers/event/EventTransactionalGraph.java
@@ -18,28 +18,10 @@ public EventTransactionalGraph(final T baseGraph) {
@Override
public void stopTransaction(Conclusion conclusion) {
-
- // failure in this context doesn't mean Conclusion.FAILURE. it means that the
- // state of closing out the transaction failed (in the setting of either one of
- // the available conclusions. in other words, an exception occurred by calling
- // success/failure or a finishing of the transaction in any way. if the transaction
- // was not a failure in that sense then events are fired (if success) and the buffer
- // is reset.
- boolean transactionFailure = false;
- try {
- this.baseGraph.stopTransaction(conclusion);
- } catch (RuntimeException re) {
- transactionFailure = true;
- throw re;
- } finally {
- if (!transactionFailure) {
- if (conclusion == Conclusion.SUCCESS) {
- trigger.fireEventQueue();
- }
-
- this.trigger.resetEventQueue();
- }
- }
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
/**
View
26 ...n/java/com/tinkerpop/blueprints/util/wrappers/event/EventTransactionalIndexableGraph.java
@@ -21,28 +21,10 @@ public EventTransactionalIndexableGraph(final T baseIndexableGraph) {
@Override
public void stopTransaction(Conclusion conclusion) {
-
- // failure in this context doesn't mean Conclusion.FAILURE. it means that the
- // state of closing out the transaction failed (in the setting of either one of
- // the available conclusions. in other words, an exception occurred by calling
- // success/failure or a finishing of the transaction in any way. if the transaction
- // was not a failure in that sense then events are fired (if success) and the buffer
- // is reset.
- boolean transactionFailure = false;
- try {
- this.baseGraph.stopTransaction(conclusion);
- } catch (RuntimeException re) {
- transactionFailure = true;
- throw re;
- } finally {
- if (!transactionFailure) {
- if (conclusion == Conclusion.SUCCESS) {
- trigger.fireEventQueue();
- }
-
- this.trigger.resetEventQueue();
- }
- }
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
/**
View
7 blueprints-core/src/main/java/com/tinkerpop/blueprints/util/wrappers/id/IdGraph.java
@@ -227,9 +227,10 @@ public void removeEdge(final Edge edge) {
// Note: this is a no-op if the base graph is not an instance of TransactionalGraph
public void stopTransaction(Conclusion conclusion) {
- if (baseGraph instanceof TransactionalGraph) {
- ((TransactionalGraph) baseGraph).stopTransaction(conclusion);
- }
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
public void rollback() {
View
40 blueprints-dex-graph/src/main/java/com/tinkerpop/blueprints/impls/dex/DexGraph.java
@@ -88,12 +88,14 @@ protected String initialValue() {
private com.sparsity.dex.gdb.Dex dex = null;
private com.sparsity.dex.gdb.Database db = null;
-
+
private class Metadata {
com.sparsity.dex.gdb.Session session = null;
List<DexIterable<? extends Element>> collection = null;
- };
-
+ }
+
+ ;
+
private ThreadLocal<Metadata> sessionData = new ThreadLocal<Metadata>() {
@Override
protected Metadata initialValue() {
@@ -602,7 +604,7 @@ protected void closeAllSessionCollections() {
@Override
public void shutdown() {
commit();
-
+
db.close();
dex.close();
}
@@ -766,16 +768,15 @@ void autoStartTransaction() {
}
public void commit() {
- com.sparsity.dex.gdb.Session sess = getRawSession(false);
- if (sess == null) {
+ if (sessionData.get().session == null) {
// already closed session
return;
}
closeAllSessionCollections();
- if (sess != null && !sess.isClosed()) {
- sess.close();
+ if (sessionData.get().session != null && !sessionData.get().session.isClosed()) {
+ sessionData.get().session.close();
}
- sessionData.set(null);
+ sessionData.get().session = null;
}
public void rollback() {
@@ -784,22 +785,9 @@ public void rollback() {
@Override
public void stopTransaction(Conclusion conclusion) {
- if (sessionData.get().session == null) {
- // already closed session
- return;
- }
- if (Conclusion.FAILURE == conclusion) {
- throw new UnsupportedOperationException("FAILURE conclusion is not supported");
- }
- //
- // Close Session
- //
- closeAllSessionCollections();
- if (sessionData.get().session != null && !sessionData.get().session.isClosed()) {
- sessionData.get().session.close();
- }
- sessionData.get().session = null;
-
- //System.out.println("< th=" + Thread.currentThread().getId() + " ends tx with sess=" + sess);
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
}
View
19 blueprints-neo4j-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j/Neo4jGraph.java
@@ -443,20 +443,11 @@ public void removeEdge(final Edge edge) {
((Relationship) ((Neo4jEdge) edge).getRawElement()).delete();
}
- public void stopTransaction(final Conclusion conclusion) {
- if (null == tx.get()) {
- return;
- }
-
- try {
- if (conclusion.equals(Conclusion.SUCCESS))
- tx.get().success();
- else
- tx.get().failure();
- } finally {
- tx.get().finish();
- tx.remove();
- }
+ public void stopTransaction(Conclusion conclusion) {
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
public void commit() {
View
10 blueprints-orient-graph/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientGraph.java
@@ -69,11 +69,11 @@ public OrientGraph(final String url, final String username, final String passwor
}
@Override
- public void stopTransaction(final Conclusion conclusion) {
- if (conclusion == Conclusion.FAILURE) {
- this.getRawGraph().rollback();
- } else
- this.getRawGraph().commit();
+ public void stopTransaction(Conclusion conclusion) {
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
public void commit() {
View
15 blueprints-sail-graph/src/main/java/com/tinkerpop/blueprints/impls/sail/SailGraph.java
@@ -423,16 +423,11 @@ public String prefixNamespace(String uri) {
return uri;
}
- public void stopTransaction(final Conclusion conclusion) {
- try {
- if (Conclusion.SUCCESS == conclusion) {
- this.sailConnection.get().commit();
- } else {
- this.sailConnection.get().rollback();
- }
- } catch (SailException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
+ public void stopTransaction(Conclusion conclusion) {
+ if (Conclusion.SUCCESS == conclusion)
+ commit();
+ else
+ rollback();
}
public void commit() {
View
4 ...rints-test/src/test/java/com/tinkerpop/blueprints/util/wrappers/batch/BatchGraphTest.java
@@ -279,11 +279,11 @@ public void stopTransaction(Conclusion conclusion) {
}
public void rollback() {
- this.rollback();
+ this.stopTransaction(Conclusion.FAILURE);
}
public void commit() {
- this.commit();
+ this.stopTransaction(Conclusion.SUCCESS);
}
@Override

0 comments on commit 1c3404f

Please sign in to comment.
Something went wrong with that request. Please try again.