incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [5/5] git commit: Adding some rollback code.
Date Mon, 06 Jan 2014 20:42:36 GMT
Adding some rollback code.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/0b037473
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/0b037473
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/0b037473

Branch: refs/heads/master
Commit: 0b0374732f7a64d631d05c7bb4b5211d5e4779ba
Parents: 9bbcff0
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Jan 6 15:41:03 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Jan 6 15:42:18 2014 -0500

----------------------------------------------------------------------
 .../apache/blur/manager/writer/BlurIndexSimpleWriter.java   | 7 +++++--
 .../org/apache/blur/manager/writer/MutatableAction.java     | 9 ++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0b037473/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
index d56df25..7fccd46 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
@@ -282,11 +282,14 @@ public class BlurIndexSimpleWriter extends BlurIndex {
   @Override
   public void process(MutatableAction mutatableAction) throws IOException {
     _writeLock.lock();
+    waitUntilNotNull(_writer);
+    BlurIndexWriter writer = _writer.get();
     try {
-      waitUntilNotNull(_writer);
-      BlurIndexWriter writer = _writer.get();
       mutatableAction.performMutate(_indexReader.get(), writer);
       commit();
+    } catch (Exception e) {
+      writer.rollback();
+      throw new IOException("Unknown error during mutation", e);
     } finally {
       _writeLock.unlock();
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0b037473/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java b/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java
index ccb1fa6..3bc8c29 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/MutatableAction.java
@@ -359,10 +359,13 @@ public class MutatableAction {
   }
 
   void performMutate(IndexReader reader, IndexWriter writer) throws IOException {
-    for (InternalAction internalAction : _actions) {
-      internalAction.performAction(reader, writer);
+    try {
+      for (InternalAction internalAction : _actions) {
+        internalAction.performAction(reader, writer);
+      }
+    } finally {
+      _actions.clear();
     }
-    _actions.clear();
   }
 
   public static Term createRowId(String id) {


Mime
View raw message