incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/2] git commit: Fixing some unit tests and compiler errors.
Date Thu, 20 Feb 2014 23:18:11 GMT
Fixing some unit tests and compiler errors.


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

Branch: refs/heads/apache-blur-0.2
Commit: bb4387e6cd2345cf72f80bb427771c801c233a76
Parents: bebe68c
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Thu Feb 20 18:17:38 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu Feb 20 18:17:38 2014 -0500

----------------------------------------------------------------------
 .../blur/manager/writer/BlurIndexReadOnly.java  |  4 +-
 .../apache/blur/manager/writer/IndexAction.java |  9 +--
 .../blur/manager/writer/IndexImporter.java      |  9 +--
 .../blur/manager/writer/MutatableAction.java    |  9 +--
 .../blur/manager/writer/IndexImporterTest.java  | 81 +++++++++++++++++++-
 5 files changed, 94 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/bb4387e6/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexReadOnly.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexReadOnly.java
b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexReadOnly.java
index 06d3979..9819952 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexReadOnly.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexReadOnly.java
@@ -73,8 +73,10 @@ public class BlurIndexReadOnly extends BlurIndex {
   }
 
   @Override
-  public void process(MutatableAction mutatableAction) {
+  public void process(IndexAction indexAction) throws IOException {
     throw new RuntimeException("Read-only shard");
   }
 
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/bb4387e6/blur-core/src/main/java/org/apache/blur/manager/writer/IndexAction.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/IndexAction.java b/blur-core/src/main/java/org/apache/blur/manager/writer/IndexAction.java
index 8fc9272..4fee343 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/writer/IndexAction.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/IndexAction.java
@@ -19,18 +19,17 @@ package org.apache.blur.manager.writer;
 import java.io.IOException;
 
 import org.apache.blur.server.IndexSearcherClosable;
-import org.apache.lucene.index.BlurIndexWriter;
 import org.apache.lucene.index.IndexWriter;
 
 public abstract class IndexAction {
 
-  public abstract void doPreCommit(IndexSearcherClosable indexSearcher, BlurIndexWriter writer)
throws IOException;
+  public abstract void doPreCommit(IndexSearcherClosable indexSearcher, IndexWriter writer)
throws IOException;
 
-  public abstract void doPostCommit(BlurIndexWriter writer) throws IOException;
+  public abstract void doPostCommit(IndexWriter writer) throws IOException;
 
-  public abstract void doPreRollback(BlurIndexWriter writer) throws IOException;
+  public abstract void doPreRollback(IndexWriter writer) throws IOException;
 
-  public abstract void doPostRollback(BlurIndexWriter writer) throws IOException;
+  public abstract void doPostRollback(IndexWriter writer) throws IOException;
 
   public abstract void performMutate(IndexSearcherClosable searcher, IndexWriter writer)
throws IOException;
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/bb4387e6/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java b/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java
index 29b5332..0510f84 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/IndexImporter.java
@@ -43,7 +43,6 @@ import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.io.Text;
 import org.apache.lucene.index.AtomicReader;
 import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.BlurIndexWriter;
 import org.apache.lucene.index.CompositeReaderContext;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.Fields;
@@ -155,12 +154,12 @@ public class IndexImporter extends TimerTask implements Closeable {
       }
 
       @Override
-      public void doPreCommit(IndexSearcherClosable indexSearcher, BlurIndexWriter writer)
throws IOException {
+      public void doPreCommit(IndexSearcherClosable indexSearcher, IndexWriter writer) throws
IOException {
 
       }
 
       @Override
-      public void doPostCommit(BlurIndexWriter writer) throws IOException {
+      public void doPostCommit(IndexWriter writer) throws IOException {
         LOG.info("Calling maybeMerge on the index [{0}] for [{1}/{2}]", _dirPath, _shard,
_table);
         writer.maybeMerge();
         LOG.info("Cleaning up old directory [{0}] for [{1}/{2}]", _dirPath, _shard, _table);
@@ -169,12 +168,12 @@ public class IndexImporter extends TimerTask implements Closeable {
       }
 
       @Override
-      public void doPreRollback(BlurIndexWriter writer) throws IOException {
+      public void doPreRollback(IndexWriter writer) throws IOException {
         LOG.info("Starting rollback on [{0}/{1}]", _shard, _table);
       }
 
       @Override
-      public void doPostRollback(BlurIndexWriter writer) throws IOException {
+      public void doPostRollback(IndexWriter writer) throws IOException {
         LOG.info("Finished rollback on [{0}/{1}]", _shard, _table);
         String name = _dirPath.getName();
         int lastIndexOf = name.lastIndexOf('.');

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/bb4387e6/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 cbe7ee2..c8f0dfd 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
@@ -42,7 +42,6 @@ import org.apache.blur.thrift.generated.Selector;
 import org.apache.blur.utils.BlurConstants;
 import org.apache.blur.utils.RowDocumentUtil;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.index.BlurIndexWriter;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
 
@@ -358,22 +357,22 @@ public class MutatableAction extends IndexAction {
   }
 
   @Override
-  public void doPreCommit(IndexSearcherClosable indexSearcher, BlurIndexWriter writer) {
+  public void doPreCommit(IndexSearcherClosable indexSearcher, IndexWriter writer) {
 
   }
 
   @Override
-  public void doPostCommit(BlurIndexWriter writer) {
+  public void doPostCommit(IndexWriter writer) {
 
   }
 
   @Override
-  public void doPreRollback(BlurIndexWriter writer) {
+  public void doPreRollback(IndexWriter writer) {
 
   }
 
   @Override
-  public void doPostRollback(BlurIndexWriter writer) {
+  public void doPostRollback(IndexWriter writer) {
 
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/bb4387e6/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java
b/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java
index 4772420..4229c0d 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java
@@ -26,9 +26,10 @@ import java.util.List;
 import java.util.Random;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.blur.analysis.FieldManager;
+import org.apache.blur.server.IndexSearcherClosable;
 import org.apache.blur.server.ShardContext;
 import org.apache.blur.server.TableContext;
 import org.apache.blur.store.buffer.BufferStore;
@@ -42,6 +43,7 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.NoMergePolicy;
@@ -101,14 +103,89 @@ public class IndexImporterTest {
     conf.setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES);
     _commitWriter = new IndexWriter(commitDirectory, conf.clone());
 
+    // Make sure there's an empty index...
+    new IndexWriter(mainDirectory, conf.clone()).close();
     _mainWriter = new IndexWriter(mainDirectory, conf.clone());
     BufferStore.initNewBuffer(128, 128 * 128);
 
-    _indexImporter = new IndexImporter(_mainWriter, new ReentrantReadWriteLock(), shardContext,
TimeUnit.MINUTES, 10);
+    _indexImporter = new IndexImporter(getBlurIndex(shardContext, mainDirectory), shardContext,
TimeUnit.MINUTES, 10);
+  }
+
+  private BlurIndex getBlurIndex(ShardContext shardContext, final Directory mainDirectory)
throws IOException {
+    return new BlurIndex(shardContext, mainDirectory, null, null, null, null, null, null)
{
+
+      @Override
+      public void removeSnapshot(String name) throws IOException {
+        throw new RuntimeException("Not Implemented");
+      }
+
+      @Override
+      public void refresh() throws IOException {
+        throw new RuntimeException("Not Implemented");
+      }
+
+      @Override
+      public void process(IndexAction indexAction) throws IOException {
+        final DirectoryReader reader = DirectoryReader.open(mainDirectory);
+        IndexSearcherClosable searcherClosable = new IndexSearcherClosable(reader, null)
{
+
+          @Override
+          public Directory getDirectory() {
+            return mainDirectory;
+          }
+
+          @Override
+          public void close() throws IOException {
+            reader.close();
+          }
+        };
+        try {
+          indexAction.performMutate(searcherClosable, _mainWriter);
+          indexAction.doPreCommit(searcherClosable, _mainWriter);
+          _mainWriter.commit();
+          indexAction.doPostCommit(_mainWriter);
+        } catch (IOException e) {
+          indexAction.doPreRollback(_mainWriter);
+          _mainWriter.rollback();
+          indexAction.doPostRollback(_mainWriter);
+        }
+      }
+
+      @Override
+      public void optimize(int numberOfSegmentsPerShard) throws IOException {
+        throw new RuntimeException("Not Implemented");
+      }
+
+      @Override
+      public AtomicBoolean isClosed() {
+        throw new RuntimeException("Not Implemented");
+      }
+
+      @Override
+      public List<String> getSnapshots() throws IOException {
+        throw new RuntimeException("Not Implemented");
+      }
+
+      @Override
+      public IndexSearcherClosable getIndexSearcher() throws IOException {
+        throw new RuntimeException("Not Implemented");
+      }
+
+      @Override
+      public void createSnapshot(String name) throws IOException {
+        throw new RuntimeException("Not Implemented");
+      }
+
+      @Override
+      public void close() throws IOException {
+        throw new RuntimeException("Not Implemented");
+      }
+    };
   }
 
   @After
   public void tearDown() throws IOException {
+    IOUtils.closeQuietly(_commitWriter);
     IOUtils.closeQuietly(_mainWriter);
     IOUtils.closeQuietly(_indexImporter);
     _base.getFileSystem(configuration).delete(_base, true);


Mime
View raw message