You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/09/03 17:33:27 UTC
[07/31] incubator-tinkerpop git commit: rollback transactions in case
of an error
rollback transactions in case of an error
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/e3bfeec6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/e3bfeec6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/e3bfeec6
Branch: refs/heads/master
Commit: e3bfeec66c96ef76fde26f6ad422c89cc299a184
Parents: 8b7f2b9
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Mon Aug 24 20:52:00 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Mon Aug 24 20:52:00 2015 +0200
----------------------------------------------------------------------
.../bulkloading/BulkLoaderVertexProgram.java | 21 ++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e3bfeec6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
index 2aa86f2..5fa8c74 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
@@ -145,8 +145,14 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
if (null != graph) {
if (graph.features().graph().supportsTransactions()) {
LOGGER.info("Committing transaction on Graph instance: {}", graph);
- graph.tx().commit(); // TODO will Giraph/MR restart the program and re-run execute if this fails?
- LOGGER.debug("Committed transaction on Graph instance: {}", graph);
+ try {
+ graph.tx().commit(); // TODO will Giraph/MR restart the program and re-run execute if this fails?
+ LOGGER.debug("Committed transaction on Graph instance: {}", graph);
+ } catch (Exception e) {
+ LOGGER.error("Failed to commit transaction on Graph instance: {}", graph);
+ graph.tx().rollback();
+ throw e;
+ }
}
try {
graph.close();
@@ -160,6 +166,17 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
@Override
public void execute(final Vertex sourceVertex, final Messenger<Tuple> messenger, final Memory memory) {
+ try {
+ executeInternal(sourceVertex, messenger, memory);
+ } catch (Exception e) {
+ if (graph.features().graph().supportsTransactions()) {
+ graph.tx().rollback();
+ }
+ throw e;
+ }
+ }
+
+ private void executeInternal(final Vertex sourceVertex, final Messenger<Tuple> messenger, final Memory memory) {
if (memory.isInitialIteration()) {
// get or create the vertex
final Vertex targetVertex = bulkLoader.getOrCreateVertex(sourceVertex, graph, g);