incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [3/5] git commit: Split commit into 2 steps and adding more tracing.
Date Mon, 06 Jan 2014 20:42:34 GMT
Split commit into 2 steps and adding more tracing.


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

Branch: refs/heads/master
Commit: 69ee04b1e6ea615ad1a379353148eb439dc2938c
Parents: 6d62722
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Jan 5 09:29:38 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Jan 5 09:32:08 2014 -0500

----------------------------------------------------------------------
 .../manager/writer/BlurIndexSimpleWriter.java   | 24 ++++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/69ee04b1/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 5090c10..7620108 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
@@ -71,7 +71,7 @@ public class BlurIndexSimpleWriter extends BlurIndex {
   private final boolean _makeReaderExitable = true;
   private IndexImporter _indexImporter;
   private final ReadWriteLock _lock = new ReentrantReadWriteLock();
-  private final Lock _readLock = _lock.readLock();
+  private final Lock _writeLock = _lock.writeLock();
   private Thread _optimizeThread;
 
   public BlurIndexSimpleWriter(ShardContext shardContext, Directory directory, SharedMergeScheduler
mergeScheduler,
@@ -156,7 +156,7 @@ public class BlurIndexSimpleWriter extends BlurIndex {
 
   @Override
   public void replaceRow(boolean waitToBeVisible, boolean wal, Row row) throws IOException
{
-    _readLock.lock();
+    _writeLock.lock();
     Tracer trace = Trace.trace("replaceRow");
     try {
       waitUntilNotNull(_writer);
@@ -166,20 +166,20 @@ public class BlurIndexSimpleWriter extends BlurIndex {
       commit();
     } finally {
       trace.done();
-      _readLock.unlock();
+      _writeLock.unlock();
     }
   }
 
   @Override
   public void deleteRow(boolean waitToBeVisible, boolean wal, String rowId) throws IOException
{
-    _readLock.lock();
+    _writeLock.lock();
     try {
       waitUntilNotNull(_writer);
       BlurIndexWriter writer = _writer.get();
       writer.deleteDocuments(TransactionRecorder.createRowId(rowId));
       commit();
     } finally {
-      _readLock.unlock();
+      _writeLock.unlock();
     }
   }
 
@@ -256,14 +256,18 @@ public class BlurIndexSimpleWriter extends BlurIndex {
     throw new RuntimeException("not impl");
   }
 
-  private synchronized void commit() throws IOException {
-    Tracer trace1 = Trace.trace("commit");
+  private void commit() throws IOException {
+    Tracer trace1 = Trace.trace("prepareCommit");
     waitUntilNotNull(_writer);
     BlurIndexWriter writer = _writer.get();
-    writer.commit();
+    writer.prepareCommit();
     trace1.done();
 
-    Tracer trace2 = Trace.trace("index refresh");
+    Tracer trace2 = Trace.trace("commit");
+    writer.commit();
+    trace2.done();
+
+    Tracer trace3 = Trace.trace("index refresh");
     DirectoryReader currentReader = _indexReader.get();
     DirectoryReader newReader = DirectoryReader.openIfChanged(currentReader);
     if (newReader == null) {
@@ -272,7 +276,7 @@ public class BlurIndexSimpleWriter extends BlurIndex {
     }
     _indexReader.set(wrap(newReader));
     _indexCloser.close(currentReader);
-    trace2.done();
+    trace3.done();
   }
 
 }


Mime
View raw message