incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [6/6] git commit: Sorry for the huge commit, I was trying to unit test the cancel query method. I found a problem with how I was dealing with exception handling in the controller. So I created a enum type ErrorType in thrift and added to BlurException.
Date Sun, 30 Jun 2013 02:10:39 GMT
Sorry for the huge commit, I was trying to unit test the cancel query method.  I found a problem with how I was dealing with exception handling in the controller.  So I created a enum type ErrorType in thrift and added to BlurException.  So that's the first large change.  The second is the fact that I was eating BlurExceptions and just wrapping them in RTEs and they really need to be checked.  So I had to create my oen Iterable and Iterator interfaces that let me throw Exceptions.  There are probably some more changes in there but those are the big ones.  It's not complete yet but I wanted to commit this working state.


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

Branch: refs/heads/master
Commit: 7a01385e908302dfa70cb95071d84b41282bf840
Parents: e333174
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat Jun 29 22:06:45 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat Jun 29 22:06:45 2013 -0400

----------------------------------------------------------------------
 .../org/apache/blur/manager/IndexManager.java   |  67 ++-
 .../blur/manager/results/BlurIterable.java      |   7 +
 .../blur/manager/results/BlurIterator.java      |  26 ++
 .../manager/results/BlurResultIterable.java     |   3 +-
 .../results/BlurResultIterableClient.java       |  22 +-
 .../results/BlurResultIterableMultiple.java     |  27 +-
 .../results/BlurResultIterableSearcher.java     |  30 +-
 .../results/BlurResultIterableSimple.java       |   7 +-
 .../BlurResultPeekableIteratorComparator.java   |   6 +-
 .../results/MergerBlurResultIterable.java       |   3 +-
 .../blur/manager/results/PeekableIterator.java  |  50 +--
 .../blur/thrift/BlurControllerServer.java       |  21 +-
 .../org/apache/blur/thrift/BlurShardServer.java |   9 +-
 .../java/org/apache/blur/thrift/TableAdmin.java |  24 +-
 .../java/org/apache/blur/utils/BlurUtil.java    |  27 +-
 .../apache/blur/utils/IterableConverter.java    |   9 +-
 .../apache/blur/utils/IteratorConverter.java    |   9 +-
 .../apache/blur/manager/IndexManagerTest.java   |  41 +-
 ...lurResultPeekableIteratorComparatorTest.java |  26 +-
 .../results/MultipleBlurResultIterableTest.java |   7 +-
 .../manager/results/PeekableIteratorTest.java   |   9 +-
 .../org/apache/blur/thrift/BlurClusterTest.java |  42 ++
 .../org/apache/blur/mapreduce/BlurReducer.java  |  32 +-
 .../blur/lucene/search/IterablePaging.java      |  13 +-
 .../blur/lucene/search/SlowCollector.java       |  60 +++
 .../apache/blur/lucene/search/SuperQuery.java   |   2 +-
 .../blur/lucene/serializer/ProtoSerializer.java |   2 +-
 .../lucene/serializer/SuperQueryWritable.java   |   2 +-
 .../blur/lucene/search/FacetQueryTest.java      |   3 +-
 .../lucene/search/RandomSuperQueryTest.java     |   1 -
 .../blur/lucene/search/SuperQueryTest.java      |   2 -
 .../lucene/search/TestingPagingCollector.java   |   4 +-
 .../blur/search/RandomSuperQueryTest.java       | 152 -------
 .../org/apache/blur/search/SuperQueryTest.java  | 205 ---------
 .../blur/search/TestingPagingCollector.java     |  84 ----
 .../java/org/apache/blur/thrift/BException.java |   3 +-
 .../thrift/generated/BackPressureException.java | 420 -------------------
 .../org/apache/blur/thrift/generated/Blur.java  | 246 +----------
 .../blur/thrift/generated/BlurException.java    | 124 +++++-
 .../apache/blur/thrift/generated/ErrorType.java |  70 ++++
 .../src/main/scripts/interface/Blur.thrift      |  23 +-
 .../main/scripts/interface/gen-html/Blur.html   |  19 +-
 .../main/scripts/interface/gen-html/index.html  |   2 +-
 .../thrift/generated/BackPressureException.java | 420 -------------------
 .../org/apache/blur/thrift/generated/Blur.java  | 246 +----------
 .../blur/thrift/generated/BlurException.java    | 124 +++++-
 .../apache/blur/thrift/generated/ErrorType.java |  70 ++++
 .../src/main/scripts/interface/gen-js/Blur.js   |  48 ---
 .../main/scripts/interface/gen-js/Blur_types.js |  72 +---
 .../scripts/interface/gen-perl/Blur/Blur.pm     |  42 --
 .../scripts/interface/gen-perl/Blur/Types.pm    |  83 +---
 .../src/main/scripts/interface/gen-rb/blur.rb   |  14 +-
 .../main/scripts/interface/gen-rb/blur_types.rb |  39 +-
 53 files changed, 905 insertions(+), 2194 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
index 7280ca7..637ef81 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
@@ -52,6 +52,7 @@ import org.apache.blur.index.ExitableReader.ExitingReaderException;
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
 import org.apache.blur.lucene.search.FacetQuery;
+import org.apache.blur.lucene.search.StopExecutionCollector.StopExecutionCollectorException;
 import org.apache.blur.manager.clusterstatus.ClusterStatus;
 import org.apache.blur.manager.results.BlurResultIterable;
 import org.apache.blur.manager.results.BlurResultIterableSearcher;
@@ -68,10 +69,12 @@ import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
 import org.apache.blur.thrift.generated.BlurQueryStatus;
 import org.apache.blur.thrift.generated.Column;
+import org.apache.blur.thrift.generated.ErrorType;
 import org.apache.blur.thrift.generated.ExpertQuery;
 import org.apache.blur.thrift.generated.FetchResult;
 import org.apache.blur.thrift.generated.FetchRowResult;
 import org.apache.blur.thrift.generated.HighlightOptions;
+import org.apache.blur.thrift.generated.QueryState;
 import org.apache.blur.thrift.generated.Record;
 import org.apache.blur.thrift.generated.RecordMutation;
 import org.apache.blur.thrift.generated.RecordMutationType;
@@ -140,6 +143,8 @@ public class IndexManager {
   private Meter _queriesInternalMeter;
   private Timer _fetchTimer;
 
+  public static AtomicBoolean DEBUG_RUN_SLOW = new AtomicBoolean(false);
+
   public void setMaxClauseCount(int maxClauseCount) {
     BooleanQuery.setMaxClauseCount(maxClauseCount);
   }
@@ -193,12 +198,12 @@ public class IndexManager {
       Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table);
       if (blurIndexes == null) {
         LOG.error("Table [{0}] not found", table);
-        throw new BlurException("Table [" + table + "] not found", null);
+        throw new BException("Table [" + table + "] not found");
       }
       index = blurIndexes.get(shard);
       if (index == null) {
         LOG.error("Shard [{0}] not found in table [{1}]", shard, table);
-        throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]", null);
+        throw new BException("Shard [" + shard + "] not found in table [" + table + "]");
       }
     } catch (BlurException e) {
       throw e;
@@ -275,7 +280,7 @@ public class IndexManager {
     Map<String, BlurIndex> indexes = _indexServer.getIndexes(table);
     BlurIndex blurIndex = indexes.get(shardName);
     if (blurIndex == null) {
-      throw new BlurException("Shard [" + shardName + "] is not being servered by this shardserver.", null);
+      throw new BException("Shard [" + shardName + "] is not being servered by this shardserver.");
     }
     IndexSearcherClosable searcher = blurIndex.getIndexReader();
     try {
@@ -315,25 +320,25 @@ public class IndexManager {
 
     if (locationId != null) {
       if (recordId != null && rowId != null) {
-        throw new BlurException("Invalid selector locationId [" + locationId + "] and recordId [" + recordId
-            + "] and rowId [" + rowId + "] are set, if using locationId, then rowId and recordId are not needed.", null);
+        throw new BException("Invalid selector locationId [" + locationId + "] and recordId [" + recordId
+            + "] and rowId [" + rowId + "] are set, if using locationId, then rowId and recordId are not needed.");
       } else if (recordId != null) {
-        throw new BlurException("Invalid selector locationId [" + locationId + "] and recordId [" + recordId
-            + "] sre set, if using locationId recordId is not needed.", null);
+        throw new BException("Invalid selector locationId [" + locationId + "] and recordId [" + recordId
+            + "] sre set, if using locationId recordId is not needed.");
       } else if (rowId != null) {
-        throw new BlurException("Invalid selector locationId [" + locationId + "] and rowId [" + rowId
-            + "] are set, if using locationId rowId is not needed.", null);
+        throw new BException("Invalid selector locationId [" + locationId + "] and rowId [" + rowId
+            + "] are set, if using locationId rowId is not needed.");
       }
     } else {
       if (rowId != null && recordId != null) {
         if (!recordOnly) {
-          throw new BlurException("Invalid both rowid [" + rowId + "] and recordId [" + recordId
+          throw new BException("Invalid both rowid [" + rowId + "] and recordId [" + recordId
               + "] are set, and recordOnly is set to [false].  "
-              + "If you want entire row, then remove recordId, if you want record only set recordOnly to [true].", null);
+              + "If you want entire row, then remove recordId, if you want record only set recordOnly to [true].");
         }
       } else if (recordId != null) {
-        throw new BlurException("Invalid recordId [" + recordId
-            + "] is set but rowId is not set.  If rowId is not known then a query will be required.", null);
+        throw new BException("Invalid recordId [" + recordId
+            + "] is set but rowId is not set.  If rowId is not known then a query will be required.");
       }
     }
   }
@@ -354,6 +359,7 @@ public class IndexManager {
 
   public BlurResultIterable query(final String table, final BlurQuery blurQuery, AtomicLongArray facetedCounts)
       throws Exception {
+    boolean runSlow = DEBUG_RUN_SLOW.get();
     final AtomicBoolean running = new AtomicBoolean(true);
     final QueryStatus status = _statusManager.newQueryStatus(table, blurQuery, _threadCount, running);
     _queriesExternalMeter.mark();
@@ -380,7 +386,7 @@ public class IndexManager {
         Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer, context, postFilter,
             preFilter);
         call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector,
-            _queriesInternalMeter, shardServerContext);
+            _queriesInternalMeter, shardServerContext, runSlow);
       } else {
         Query query = getQuery(blurQuery.expertQuery);
         Filter filter = getFilter(blurQuery.expertQuery);
@@ -392,7 +398,7 @@ public class IndexManager {
         }
         Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer, context, null, null);
         call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery, blurQuery.selector,
-            _queriesInternalMeter, shardServerContext);
+            _queriesInternalMeter, shardServerContext, runSlow);
       }
       MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery);
       return ForkJoin.execute(_executor, blurIndexes.entrySet(), call, new Cancel() {
@@ -401,6 +407,24 @@ public class IndexManager {
           running.set(false);
         }
       }).merge(merger);
+    } catch (StopExecutionCollectorException e) {
+      BlurQueryStatus queryStatus = status.getQueryStatus();
+      QueryState state = queryStatus.getState();
+      if (state == QueryState.BACK_PRESSURE_INTERRUPTED) {
+        throw new BlurException("Cannot execute query right now.", null, ErrorType.BACK_PRESSURE);  
+      } else if (state == QueryState.INTERRUPTED) {
+        throw new BlurException("Cannot execute query right now.", null, ErrorType.QUERY_CANCEL);
+      }
+      throw e;
+    } catch (ExitingReaderException e) {
+      BlurQueryStatus queryStatus = status.getQueryStatus();
+      QueryState state = queryStatus.getState();
+      if (state == QueryState.BACK_PRESSURE_INTERRUPTED) {
+        throw new BlurException("Cannot execute query right now.", null, ErrorType.BACK_PRESSURE);  
+      } else if (state == QueryState.INTERRUPTED) {
+        throw new BlurException("Cannot execute query right now.", null, ErrorType.QUERY_CANCEL);
+      }
+      throw e;
     } finally {
       _statusManager.removeStatus(status);
     }
@@ -860,8 +884,7 @@ public class IndexManager {
       }
       BlurIndex blurIndex = indexes.get(shard);
       if (blurIndex == null) {
-        throw new BlurException("Shard [" + shard + "] in table [" + table + "] is not being served by this server.",
-            null);
+        throw new BException("Shard [" + shard + "] in table [" + table + "] is not being served by this server.");
       }
 
       boolean waitVisiblity = false;
@@ -909,8 +932,7 @@ public class IndexManager {
     String shard = MutationHelper.getShardName(table, mutation.rowId, getNumberOfShards(table), _blurPartitioner);
     BlurIndex blurIndex = indexes.get(shard);
     if (blurIndex == null) {
-      throw new BlurException("Shard [" + shard + "] in table [" + table + "] is not being served by this server.",
-          null);
+      throw new BException("Shard [" + shard + "] in table [" + table + "] is not being served by this server.");
     }
 
     RowMutationType type = mutation.rowMutationType;
@@ -1048,9 +1070,11 @@ public class IndexManager {
     private final AtomicBoolean _running;
     private final Meter _queriesInternalMeter;
     private final ShardServerContext _shardServerContext;
+    private final boolean _runSlow;
 
     public SimpleQueryParallelCall(AtomicBoolean running, String table, QueryStatus status, IndexServer indexServer,
-        Query query, Selector selector, Meter queriesInternalMeter, ShardServerContext shardServerContext) {
+        Query query, Selector selector, Meter queriesInternalMeter, ShardServerContext shardServerContext,
+        boolean runSlow) {
       _running = running;
       _table = table;
       _status = status;
@@ -1059,6 +1083,7 @@ public class IndexManager {
       _selector = selector;
       _queriesInternalMeter = queriesInternalMeter;
       _shardServerContext = shardServerContext;
+      _runSlow = runSlow;
     }
 
     @Override
@@ -1090,7 +1115,7 @@ public class IndexManager {
         // BlurResultIterableSearcher will close searcher, if shard server
         // context is null.
         return new BlurResultIterableSearcher(_running, rewrite, _table, shard, searcher, _selector,
-            _shardServerContext == null);
+            _shardServerContext == null, _runSlow);
       } finally {
         _queriesInternalMeter.mark();
         _status.deattachThread(shard);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/BlurIterable.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurIterable.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurIterable.java
new file mode 100644
index 0000000..5084aae
--- /dev/null
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurIterable.java
@@ -0,0 +1,7 @@
+package org.apache.blur.manager.results;
+
+public interface BlurIterable<T, E extends Exception> {
+
+  BlurIterator<T, E> iterator() throws E;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/BlurIterator.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurIterator.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurIterator.java
new file mode 100644
index 0000000..e9169c3
--- /dev/null
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurIterator.java
@@ -0,0 +1,26 @@
+package org.apache.blur.manager.results;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+public interface BlurIterator<T, E extends Exception> {
+
+  public boolean hasNext() throws E;
+
+  public T next() throws E;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterable.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterable.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterable.java
index 517920a..c9f8436 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterable.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterable.java
@@ -19,9 +19,10 @@ package org.apache.blur.manager.results;
 import java.io.Closeable;
 import java.util.Map;
 
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
 
-public interface BlurResultIterable extends Iterable<BlurResult>, Closeable {
+public interface BlurResultIterable extends BlurIterable<BlurResult, BlurException>, Closeable {
 
   void skipTo(long skipTo);
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java
index 9cf7dd7..b506194 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableClient.java
@@ -17,7 +17,6 @@ package org.apache.blur.manager.results;
  * limitations under the License.
  */
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -28,10 +27,12 @@ import org.apache.blur.log.LogFactory;
 import org.apache.blur.thrift.BlurClientManager;
 import org.apache.blur.thrift.Connection;
 import org.apache.blur.thrift.generated.Blur;
+import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
 import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.thrift.generated.BlurResults;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.ErrorType;
 
 public class BlurResultIterableClient implements BlurResultIterable {
 
@@ -79,6 +80,14 @@ public class BlurResultIterableClient implements BlurResultIterable {
       _totalResults = _results.totalResults;
       _shardInfo.putAll(_results.shardInfo);
       _batch++;
+    } catch (BlurException e) {
+      ErrorType errorType = e.getErrorType();
+      if (errorType == ErrorType.UNKNOWN) {
+        LOG.error("Error during for [{0}]", e, _originalQuery);
+        throw new RuntimeException(e);
+      }
+      LOG.info("Error during for [{0}]", e, _originalQuery);
+
     } catch (Exception e) {
       LOG.error("Error during for [{0}]", e, _originalQuery);
       throw new RuntimeException(e);
@@ -125,7 +134,7 @@ public class BlurResultIterableClient implements BlurResultIterable {
   }
 
   @Override
-  public Iterator<BlurResult> iterator() {
+  public BlurIterator<BlurResult, BlurException> iterator() {
     SearchIterator iterator = new SearchIterator();
     long start = 0;
     while (iterator.hasNext() && start < _skipTo) {
@@ -135,7 +144,7 @@ public class BlurResultIterableClient implements BlurResultIterable {
     return iterator;
   }
 
-  public class SearchIterator implements Iterator<BlurResult> {
+  public class SearchIterator implements BlurIterator<BlurResult, BlurException> {
 
     private int position = 0;
     private int relposition = 0;
@@ -157,11 +166,6 @@ public class BlurResultIterableClient implements BlurResultIterable {
       position++;
       return _results.results.get(relposition++);
     }
-
-    @Override
-    public void remove() {
-
-    }
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableMultiple.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableMultiple.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableMultiple.java
index 8d84395..536ff19 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableMultiple.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableMultiple.java
@@ -19,20 +19,19 @@ package org.apache.blur.manager.results;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.utils.BlurUtil;
 import org.apache.hadoop.io.IOUtils;
 
-
 public class BlurResultIterableMultiple implements BlurResultIterable {
-  
+
   private static final Log LOG = LogFactory.getLog(BlurResultIterableMultiple.class);
 
   private long totalResults;
@@ -62,7 +61,7 @@ public class BlurResultIterableMultiple implements BlurResultIterable {
   }
 
   @Override
-  public Iterator<BlurResult> iterator() {
+  public BlurIterator<BlurResult, BlurException> iterator() throws BlurException {
     MultipleHitsIterator iterator = new MultipleHitsIterator(results);
     long start = 0;
     while (iterator.hasNext() && start < skipTo) {
@@ -72,20 +71,23 @@ public class BlurResultIterableMultiple implements BlurResultIterable {
     return iterator;
   }
 
-  public static class MultipleHitsIterator implements Iterator<BlurResult> {
+  public static class MultipleHitsIterator implements BlurIterator<BlurResult, BlurException> {
 
-    private List<PeekableIterator<BlurResult>> iterators = new ArrayList<PeekableIterator<BlurResult>>();
+    private List<PeekableIterator<BlurResult, BlurException>> iterators = new ArrayList<PeekableIterator<BlurResult, BlurException>>();
     private int length;
 
-    public MultipleHitsIterator(List<BlurResultIterable> hits) {
+    public MultipleHitsIterator(List<BlurResultIterable> hits) throws BlurException {
       for (BlurResultIterable hitsIterable : hits) {
-        iterators.add(new PeekableIterator<BlurResult>(hitsIterable.iterator()));
+        BlurIterator<BlurResult, BlurException> iterator = hitsIterable.iterator();
+//        PeekableIterator<BlurResult, BlurException> peekableIterator = new PeekableIterator<BlurResult, BlurException>(iterator);
+        PeekableIterator<BlurResult, BlurException> peekableIterator = PeekableIterator.wrap(iterator);
+        iterators.add(peekableIterator);
       }
       length = iterators.size();
     }
 
     @Override
-    public boolean hasNext() {
+    public boolean hasNext() throws BlurException {
       for (int i = 0; i < length; i++) {
         if (iterators.get(i).hasNext()) {
           return true;
@@ -95,7 +97,7 @@ public class BlurResultIterableMultiple implements BlurResultIterable {
     }
 
     @Override
-    public BlurResult next() {
+    public BlurResult next() throws BlurException {
       Collections.sort(iterators, BlurUtil.HITS_PEEKABLE_ITERATOR_COMPARATOR);
       return fetchResult(iterators.get(0).next());
     }
@@ -103,11 +105,6 @@ public class BlurResultIterableMultiple implements BlurResultIterable {
     public BlurResult fetchResult(BlurResult next) {
       return next;
     }
-
-    @Override
-    public void remove() {
-
-    }
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
index ee48ccd..4c4816b 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
@@ -17,7 +17,6 @@ package org.apache.blur.manager.results;
  * limitations under the License.
  */
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -36,7 +35,6 @@ import org.apache.blur.utils.IteratorConverter;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 
-
 public class BlurResultIterableSearcher implements BlurResultIterable {
 
   private Map<String, Long> _shardInfo = new TreeMap<String, Long>();
@@ -45,7 +43,7 @@ public class BlurResultIterableSearcher implements BlurResultIterable {
   private String _table;
   private int _fetchCount = 1000;
 
-  private IteratorConverter<ScoreDoc, BlurResult> _iterator;
+  private IteratorConverter<ScoreDoc, BlurResult, BlurException> _iterator;
   private final Selector _selector;
   private final Query _query;
   private IndexSearcherClosable _searcher;
@@ -53,9 +51,10 @@ public class BlurResultIterableSearcher implements BlurResultIterable {
   private final ProgressRef _progressRef = new ProgressRef();
   private final AtomicBoolean _running;
   private final boolean _closeSearcher;
+  private final boolean _runSlow;
 
-  public BlurResultIterableSearcher(AtomicBoolean running, Query query, String table, String shard, IndexSearcherClosable searcher, Selector selector, boolean closeSearcher)
-      throws IOException {
+  public BlurResultIterableSearcher(AtomicBoolean running, Query query, String table, String shard,
+      IndexSearcherClosable searcher, Selector selector, boolean closeSearcher, boolean runSlow) throws IOException {
     _running = running;
     _table = table;
     _query = query;
@@ -63,18 +62,21 @@ public class BlurResultIterableSearcher implements BlurResultIterable {
     _searcher = searcher;
     _selector = selector;
     _closeSearcher = closeSearcher;
+    _runSlow = runSlow;
     performSearch();
   }
 
   private void performSearch() throws IOException {
-    IterablePaging iterablePaging = new IterablePaging(_running, _searcher, _query, _fetchCount, _totalHitsRef, _progressRef);
-    _iterator = new IteratorConverter<ScoreDoc, BlurResult>(iterablePaging.iterator(), new Converter<ScoreDoc, BlurResult>() {
-      @Override
-      public BlurResult convert(ScoreDoc scoreDoc) throws Exception {
-        String resolveId = resolveId(scoreDoc.doc);
-        return new BlurResult(resolveId, scoreDoc.score, getFetchResult(resolveId));
-      }
-    });
+    IterablePaging iterablePaging = new IterablePaging(_running, _searcher, _query, _fetchCount, _totalHitsRef,
+        _progressRef, _runSlow);
+    _iterator = new IteratorConverter<ScoreDoc, BlurResult, BlurException>(iterablePaging.iterator(),
+        new Converter<ScoreDoc, BlurResult>() {
+          @Override
+          public BlurResult convert(ScoreDoc scoreDoc) throws Exception {
+            String resolveId = resolveId(scoreDoc.doc);
+            return new BlurResult(resolveId, scoreDoc.score, getFetchResult(resolveId));
+          }
+        });
     _shardInfo.put(_shard, (long) _totalHitsRef.totalHits());
   }
 
@@ -105,7 +107,7 @@ public class BlurResultIterableSearcher implements BlurResultIterable {
   }
 
   @Override
-  public Iterator<BlurResult> iterator() {
+  public BlurIterator<BlurResult, BlurException> iterator() {
     long start = 0;
     while (_iterator.hasNext() && start < _skipTo) {
       _iterator.next();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSimple.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSimple.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSimple.java
index ee89959..fb6ed66 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSimple.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSimple.java
@@ -18,15 +18,14 @@ package org.apache.blur.manager.results;
  */
 import java.io.IOException;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.utils.BlurUtil;
 
-
 public class BlurResultIterableSimple implements BlurResultIterable {
 
   private List<BlurResult> results;
@@ -56,9 +55,9 @@ public class BlurResultIterableSimple implements BlurResultIterable {
   }
 
   @Override
-  public Iterator<BlurResult> iterator() {
+  public BlurIterator<BlurResult, BlurException> iterator() throws BlurException {
     long start = 0;
-    Iterator<BlurResult> iterator = results.iterator();
+    BlurIterator<BlurResult, BlurException> iterator = BlurUtil.convert(results.iterator());
     while (iterator.hasNext() && start < skipTo) {
       iterator.next();
       start++;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java
index 7eddb0a..7253af2 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparator.java
@@ -18,13 +18,13 @@ package org.apache.blur.manager.results;
  */
 import java.util.Comparator;
 
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
 
-
-public class BlurResultPeekableIteratorComparator implements Comparator<PeekableIterator<BlurResult>> {
+public class BlurResultPeekableIteratorComparator implements Comparator<PeekableIterator<BlurResult, BlurException>> {
 
   @Override
-  public int compare(PeekableIterator<BlurResult> o1, PeekableIterator<BlurResult> o2) {
+  public int compare(PeekableIterator<BlurResult, BlurException> o1, PeekableIterator<BlurResult, BlurException> o2) {
     BlurResult result1 = o1.peek();
     BlurResult result2 = o2.peek();
     if (result1 == null && result2 == null) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/MergerBlurResultIterable.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/MergerBlurResultIterable.java b/blur-core/src/main/java/org/apache/blur/manager/results/MergerBlurResultIterable.java
index 5fa9f6d..df28f97 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/MergerBlurResultIterable.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/MergerBlurResultIterable.java
@@ -23,6 +23,7 @@ import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
+import org.apache.blur.thrift.generated.ErrorType;
 import org.apache.blur.utils.BlurExecutorCompletionService;
 import org.apache.blur.utils.ForkJoin.Merger;
 
@@ -56,7 +57,7 @@ public class MergerBlurResultIterable implements Merger<BlurResultIterable> {
       } else {
         LOG.info("Query timeout with max query time of [{2}] for query [{1}].", _maxQueryTime, _blurQuery);
         throw new BlurException("Query timeout with max query time of [" + _maxQueryTime + "] for query [" + _blurQuery
-            + "].", null);
+            + "].", null, ErrorType.QUERY_TIMEOUT);
       }
     }
     return iterable;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/manager/results/PeekableIterator.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/PeekableIterator.java b/blur-core/src/main/java/org/apache/blur/manager/results/PeekableIterator.java
index 4b5b5f8..00534b2 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/PeekableIterator.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/PeekableIterator.java
@@ -1,5 +1,6 @@
 package org.apache.blur.manager.results;
 
+
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -16,51 +17,50 @@ package org.apache.blur.manager.results;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import java.util.Iterator;
-
-public class PeekableIterator<E> implements Iterator<E> {
 
-  private Iterator<E> iterator;
-  private E current;
+public class PeekableIterator<T, E extends Exception> implements BlurIterator<T, E> {
 
-  public PeekableIterator(Iterator<E> iterator) {
+  private final BlurIterator<T, E> _iterator;
+  private T _current;
+  
+  private PeekableIterator(BlurIterator<T, E> iterator,T current) {
+    _iterator = iterator;
+    _current = current;
+  }
+  
+  public static<T,E extends Exception> PeekableIterator<T, E> wrap(BlurIterator<T, E> iterator) throws E {
     if (iterator.hasNext()) {
-      current = iterator.next();
+      return new PeekableIterator<T, E>(iterator, iterator.next());
     }
-    this.iterator = iterator;
+    return new PeekableIterator<T, E>(iterator, null);
   }
 
   /**
    * Only valid is hasNext is true. If hasNext if false, peek will return null;
    * 
-   * @return <E>
+   * @return <T>
    */
-  public E peek() {
-    return current;
+  public T peek() {
+    return _current;
   }
 
   @Override
-  public boolean hasNext() {
-    if (current != null) {
+  public boolean hasNext() throws E {
+    if (_current != null) {
       return true;
     }
-    return iterator.hasNext();
+    return _iterator.hasNext();
   }
 
   @Override
-  public E next() {
-    E next = null;
-    if (iterator.hasNext()) {
-      next = iterator.next();
+  public T next() throws E {
+    T next = null;
+    if (_iterator.hasNext()) {
+      next = _iterator.next();
     }
-    E result = current;
-    current = next;
+    T result = _current;
+    _current = next;
     return result;
   }
 
-  @Override
-  public void remove() {
-
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
index 4c69b09..8ddd951 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -47,6 +46,7 @@ import org.apache.blur.manager.BlurQueryChecker;
 import org.apache.blur.manager.IndexManager;
 import org.apache.blur.manager.clusterstatus.ZookeeperPathConstants;
 import org.apache.blur.manager.indexserver.DistributedLayoutManager;
+import org.apache.blur.manager.results.BlurIterator;
 import org.apache.blur.manager.results.BlurResultIterable;
 import org.apache.blur.manager.results.BlurResultIterableClient;
 import org.apache.blur.manager.results.LazyBlurResult;
@@ -58,7 +58,6 @@ import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.commands.BlurCommand;
 import org.apache.blur.thrift.generated.Blur.Client;
 import org.apache.blur.thrift.generated.Blur.Iface;
-import org.apache.blur.thrift.generated.BackPressureException;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
 import org.apache.blur.thrift.generated.BlurQueryStatus;
@@ -299,7 +298,7 @@ public class BlurControllerServer extends TableAdmin implements Iface {
   }
 
   @Override
-  public BlurResults query(final String table, final BlurQuery blurQuery) throws BlurException, BackPressureException, TException {
+  public BlurResults query(final String table, final BlurQuery blurQuery) throws BlurException, TException {
     checkTable(table);
     String cluster = _clusterStatus.getCluster(true, table);
     _queryChecker.checkQuery(blurQuery);
@@ -363,19 +362,19 @@ public class BlurControllerServer extends TableAdmin implements Iface {
         throw new BException("Unknown error during search of [table={0},blurQuery={1}]", e, table, blurQuery);
       }
     }
-    throw new BlurException("Query could not be completed.", null);
+    throw new BException("Query could not be completed.");
   }
 
   public BlurResults convertToBlurResults(BlurResultIterable hitsIterable, BlurQuery query,
       AtomicLongArray facetCounts, ExecutorService executor, Selector selector, final String table)
-      throws InterruptedException, ExecutionException {
+      throws InterruptedException, ExecutionException, BlurException {
     BlurResults results = new BlurResults();
     results.setTotalResults(hitsIterable.getTotalResults());
     results.setShardInfo(hitsIterable.getShardInfo());
     if (query.minimumNumberOfResults > 0) {
       hitsIterable.skipTo(query.start);
       int count = 0;
-      Iterator<BlurResult> iterator = hitsIterable.iterator();
+      BlurIterator<BlurResult, BlurException> iterator = hitsIterable.iterator();
       while (iterator.hasNext() && count < query.fetch) {
         results.addToResults(iterator.next());
         count++;
@@ -424,7 +423,7 @@ public class BlurControllerServer extends TableAdmin implements Iface {
   }
 
   @Override
-  public FetchResult fetchRow(final String table, final Selector selector) throws BlurException, BackPressureException, TException {
+  public FetchResult fetchRow(final String table, final Selector selector) throws BlurException, TException {
     checkTable(table);
     IndexManager.validSelector(selector);
     String clientHostnamePort = null;
@@ -694,7 +693,7 @@ public class BlurControllerServer extends TableAdmin implements Iface {
       String shardName = MutationHelper.getShardName(table, selector.rowId, numberOfShards, _blurPartitioner);
       return layout.get(shardName);
     }
-    throw new BlurException("Selector is missing both a locationid and a rowid, one is needed.", null);
+    throw new BException("Selector is missing both a locationid and a rowid, one is needed.");
   }
 
   private <R> R scatterGather(String cluster, final BlurCommand<R> command, Merger<R> merger) throws Exception {
@@ -723,7 +722,7 @@ public class BlurControllerServer extends TableAdmin implements Iface {
   private String getCluster(String table) throws BlurException, TException {
     TableDescriptor describe = describe(table);
     if (describe == null) {
-      throw new BlurException("Table [" + table + "] not found.", null);
+      throw new BException("Table [" + table + "] not found.");
     }
     return describe.cluster;
   }
@@ -754,7 +753,7 @@ public class BlurControllerServer extends TableAdmin implements Iface {
       int numberOfShards = getShardCount(table);
       Map<String, String> tableLayout = _shardServerLayout.get().get(table);
       if (tableLayout.size() != numberOfShards) {
-        throw new BlurException("Cannot update data while shard is missing", null);
+        throw new BException("Cannot update data while shard is missing");
       }
 
       String shardName = MutationHelper.getShardName(table, mutation.rowId, numberOfShards, _blurPartitioner);
@@ -798,7 +797,7 @@ public class BlurControllerServer extends TableAdmin implements Iface {
       int numberOfShards = getShardCount(table);
       Map<String, String> tableLayout = _shardServerLayout.get().get(table);
       if (tableLayout.size() != numberOfShards) {
-        throw new BlurException("Cannot update data while shard is missing", null);
+        throw new BException("Cannot update data while shard is missing");
       }
 
       String shardName = MutationHelper.getShardName(table, mutation.rowId, numberOfShards, _blurPartitioner);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java
index 7915260..c7f18ac 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java
@@ -41,7 +41,6 @@ import org.apache.blur.manager.results.BlurResultIterable;
 import org.apache.blur.manager.writer.BlurIndex;
 import org.apache.blur.server.ShardServerContext;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.BackPressureException;
 import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
@@ -89,7 +88,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   }
 
   @Override
-  public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, BackPressureException, TException {
+  public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, TException {
     checkTable(_cluster, table);
     resetSearchers();
     _queryChecker.checkQuery(blurQuery);
@@ -121,6 +120,8 @@ public class BlurShardServer extends TableAdmin implements Iface {
         hitsIterable = _indexManager.query(table, blurQuery, facetCounts);
         return _queryCache.cache(table, original,
             BlurUtil.convertToHits(hitsIterable, blurQuery, facetCounts, _dataFetch, blurQuery.selector, this, table));
+      } catch (BlurException e) {
+        throw e;
       } catch (Exception e) {
         LOG.error("Unknown error during search of [table={0},searchQuery={1}]", e, table, blurQuery);
         throw new BException(e.getMessage(), e);
@@ -136,7 +137,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   }
 
   @Override
-  public String parseQuery(String table, SimpleQuery simpleQuery) throws BlurException, BackPressureException, TException {
+  public String parseQuery(String table, SimpleQuery simpleQuery) throws BlurException, TException {
     try {
       return _indexManager.parseQuery(table, simpleQuery);
     } catch (Throwable e) {
@@ -374,7 +375,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
       throw new BException(e.getMessage(), e);
     }
     if (blurQueryStatus == null) {
-      throw new BlurException("Query status for table [" + table + "] and uuid [" + uuid + "] not found", null);
+      throw new BException("Query status for table [" + table + "] and uuid [" + uuid + "] not found");
     }
     return blurQueryStatus;
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java b/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
index 5826e27..1d4f943 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/TableAdmin.java
@@ -110,7 +110,7 @@ public abstract class TableAdmin implements Iface {
       TableContext.clear();
       String cluster = _clusterStatus.getCluster(false, table);
       if (cluster == null) {
-        throw new BlurException("Table [" + table + "] not found.", null);
+        throw new BException("Table [" + table + "] not found.");
       }
       _clusterStatus.disableTable(cluster, table);
       waitForTheTableToDisable(cluster, table);
@@ -127,7 +127,7 @@ public abstract class TableAdmin implements Iface {
       TableContext.clear();
       String cluster = _clusterStatus.getCluster(false, table);
       if (cluster == null) {
-        throw new BlurException("Table [" + table + "] not found.", null);
+        throw new BException("Table [" + table + "] not found.");
       }
       _clusterStatus.enableTable(cluster, table);
       waitForTheTableToEnable(cluster, table);
@@ -264,7 +264,7 @@ public abstract class TableAdmin implements Iface {
       TableContext.clear();
       String cluster = _clusterStatus.getCluster(false, table);
       if (cluster == null) {
-        throw new BlurException("Table [" + table + "] not found.", null);
+        throw new BException("Table [" + table + "] not found.");
       }
       _clusterStatus.removeTable(cluster, table, deleteIndexFiles);
     } catch (Exception e) {
@@ -279,40 +279,40 @@ public abstract class TableAdmin implements Iface {
 
   public void checkTable(String table) throws BlurException {
     if (table == null) {
-      throw new BlurException("Table cannot be null.", null);
+      throw new BException("Table cannot be null.");
     }
     String cluster = _clusterStatus.getCluster(true, table);
     if (cluster == null) {
-      throw new BlurException("Table [" + table + "] does not exist", null);
+      throw new BException("Table [" + table + "] does not exist");
     }
     checkTable(cluster, table);
   }
 
   public void checkTable(String cluster, String table) throws BlurException {
     if (inSafeMode(true, table)) {
-      throw new BlurException("Cluster for [" + table + "] is in safe mode", null);
+      throw new BException("Cluster for [" + table + "] is in safe mode");
     }
     if (tableExists(true, cluster, table)) {
       if (isTableEnabled(true, cluster, table)) {
         return;
       }
-      throw new BlurException("Table [" + table + "] exists, but is not enabled", null);
+      throw new BException("Table [" + table + "] exists, but is not enabled");
     } else {
-      throw new BlurException("Table [" + table + "] does not exist", null);
+      throw new BException("Table [" + table + "] does not exist");
     }
   }
 
   public void checkForUpdates(String table) throws BlurException {
     String cluster = _clusterStatus.getCluster(true, table);
     if (cluster == null) {
-      throw new BlurException("Table [" + table + "] does not exist", null);
+      throw new BException("Table [" + table + "] does not exist");
     }
     checkForUpdates(cluster, table);
   }
 
   public void checkForUpdates(String cluster, String table) throws BlurException {
     if (_clusterStatus.isReadOnly(true, cluster, table)) {
-      throw new BlurException("Table [" + table + "] in cluster [" + cluster + "] is read only.", null);
+      throw new BException("Table [" + table + "] in cluster [" + cluster + "] is read only.");
     }
   }
 
@@ -351,7 +351,7 @@ public abstract class TableAdmin implements Iface {
     try {
       String cluster = _clusterStatus.getCluster(true, table);
       if (cluster == null) {
-        throw new BlurException("Table [" + table + "] not found.", null);
+        throw new BException("Table [" + table + "] not found.");
       }
       return _clusterStatus.getTableDescriptor(true, cluster, table);
     } catch (Exception e) {
@@ -383,7 +383,7 @@ public abstract class TableAdmin implements Iface {
   private boolean inSafeMode(boolean useCache, String table) throws BlurException {
     String cluster = _clusterStatus.getCluster(useCache, table);
     if (cluster == null) {
-      throw new BlurException("Table [" + table + "] not found.", null);
+      throw new BException("Table [" + table + "] not found.");
     }
     return _clusterStatus.isInSafeMode(useCache, cluster);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
index ef386c2..c22993f 100644
--- a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
+++ b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
@@ -52,6 +52,7 @@ import java.util.regex.Pattern;
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
 import org.apache.blur.manager.clusterstatus.ZookeeperPathConstants;
+import org.apache.blur.manager.results.BlurIterator;
 import org.apache.blur.manager.results.BlurResultComparator;
 import org.apache.blur.manager.results.BlurResultIterable;
 import org.apache.blur.manager.results.BlurResultPeekableIteratorComparator;
@@ -61,6 +62,7 @@ import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TJSONProtocol;
 import org.apache.blur.thirdparty.thrift_0_9_0.transport.TMemoryBuffer;
 import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
 import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.thrift.generated.BlurResults;
@@ -109,7 +111,7 @@ public class BlurUtil {
   private static final String UNKNOWN = "UNKNOWN";
   private static Pattern validator = Pattern.compile("^[a-zA-Z0-9\\_\\-]+$");
 
-  public static final Comparator<? super PeekableIterator<BlurResult>> HITS_PEEKABLE_ITERATOR_COMPARATOR = new BlurResultPeekableIteratorComparator();
+  public static final Comparator<? super PeekableIterator<BlurResult, BlurException>> HITS_PEEKABLE_ITERATOR_COMPARATOR = new BlurResultPeekableIteratorComparator();
   public static final Comparator<? super BlurResult> HITS_COMPARATOR = new BlurResultComparator();
   public static final Term PRIME_DOC_TERM = new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE);
 
@@ -261,14 +263,14 @@ public class BlurUtil {
 
   public static BlurResults convertToHits(BlurResultIterable hitsIterable, BlurQuery query,
       AtomicLongArray facetCounts, ExecutorService executor, Selector selector, final Iface iface, final String table)
-      throws InterruptedException, ExecutionException {
+      throws InterruptedException, ExecutionException, BlurException {
     BlurResults results = new BlurResults();
     results.setTotalResults(hitsIterable.getTotalResults());
     results.setShardInfo(hitsIterable.getShardInfo());
     if (query.minimumNumberOfResults > 0) {
       hitsIterable.skipTo(query.start);
       int count = 0;
-      Iterator<BlurResult> iterator = hitsIterable.iterator();
+      BlurIterator<BlurResult, BlurException> iterator = hitsIterable.iterator();
       while (iterator.hasNext() && count < query.fetch) {
         results.addToResults(iterator.next());
         count++;
@@ -672,4 +674,23 @@ public class BlurUtil {
   public static String getPid() {
     return ManagementFactory.getRuntimeMXBean().getName();
   }
+  
+//  public static <T> BlurIterator<T, BlurException> convert(final Iterator<T> iterator) {
+//    return convert(iterator, BlurException.class);
+//  }
+
+  public static <T, E extends Exception> BlurIterator<T, E> convert(final Iterator<T> iterator) {
+    return new BlurIterator<T, E>() {
+
+      @Override
+      public boolean hasNext() throws E {
+        return iterator.hasNext();
+      }
+
+      @Override
+      public T next() throws E {
+        return iterator.next();
+      }
+    };
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/utils/IterableConverter.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/utils/IterableConverter.java b/blur-core/src/main/java/org/apache/blur/utils/IterableConverter.java
index c6f22f1..e485d3c 100644
--- a/blur-core/src/main/java/org/apache/blur/utils/IterableConverter.java
+++ b/blur-core/src/main/java/org/apache/blur/utils/IterableConverter.java
@@ -16,9 +16,10 @@ package org.apache.blur.utils;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import java.util.Iterator;
+import org.apache.blur.manager.results.BlurIterable;
+import org.apache.blur.manager.results.BlurIterator;
 
-public class IterableConverter<F, T> implements Iterable<T> {
+public class IterableConverter<F, T, E extends Exception> implements BlurIterable<T, E> {
 
   private Converter<F, T> converter;
   private Iterable<F> iterable;
@@ -29,8 +30,8 @@ public class IterableConverter<F, T> implements Iterable<T> {
   }
 
   @Override
-  public Iterator<T> iterator() {
-    return new IteratorConverter<F, T>(iterable.iterator(), converter);
+  public BlurIterator<T, E> iterator() {
+    return new IteratorConverter<F, T, E>(iterable.iterator(), converter);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/main/java/org/apache/blur/utils/IteratorConverter.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/utils/IteratorConverter.java b/blur-core/src/main/java/org/apache/blur/utils/IteratorConverter.java
index 24d769e..62cb8fa 100644
--- a/blur-core/src/main/java/org/apache/blur/utils/IteratorConverter.java
+++ b/blur-core/src/main/java/org/apache/blur/utils/IteratorConverter.java
@@ -18,7 +18,9 @@ package org.apache.blur.utils;
  */
 import java.util.Iterator;
 
-public class IteratorConverter<F, T> implements Iterator<T> {
+import org.apache.blur.manager.results.BlurIterator;
+
+public class IteratorConverter<F, T, E extends Exception> implements BlurIterator<T, E> {
 
   private Converter<F, T> converter;
   private Iterator<F> iterator;
@@ -42,9 +44,4 @@ public class IteratorConverter<F, T> implements Iterator<T> {
     }
   }
 
-  @Override
-  public void remove() {
-    iterator.remove();
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
index 837d0a2..8d7664f 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
@@ -47,6 +47,7 @@ import java.util.concurrent.atomic.AtomicLongArray;
 
 import org.apache.blur.manager.clusterstatus.ClusterStatus;
 import org.apache.blur.manager.indexserver.LocalIndexServer;
+import org.apache.blur.manager.results.BlurIterator;
 import org.apache.blur.manager.results.BlurResultIterable;
 import org.apache.blur.server.TableContext;
 import org.apache.blur.thrift.generated.AnalyzerDefinition;
@@ -361,7 +362,9 @@ public class IndexManagerTest {
 
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null);
     assertEquals(iterable.getTotalResults(), 1);
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       Selector selector = new Selector().setLocationId(result.getLocationId());
       FetchResult fetchResult = new FetchResult();
       indexManager.fetchRow(TABLE, selector, fetchResult);
@@ -384,7 +387,9 @@ public class IndexManagerTest {
 
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null);
     assertEquals(iterable.getTotalResults(), 1);
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       Selector selector = new Selector().setLocationId(result.getLocationId());
       FetchResult fetchResult = new FetchResult();
       indexManager.fetchRow(TABLE, selector, fetchResult);
@@ -407,7 +412,9 @@ public class IndexManagerTest {
 
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null);
     assertEquals(iterable.getTotalResults(), 1);
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       Selector selector = new Selector().setLocationId(result.getLocationId());
       FetchResult fetchResult = new FetchResult();
       indexManager.fetchRow(TABLE, selector, fetchResult);
@@ -433,7 +440,9 @@ public class IndexManagerTest {
     AtomicLongArray facetedCounts = new AtomicLongArray(2);
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, facetedCounts);
     assertEquals(iterable.getTotalResults(), 2);
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       Selector selector = new Selector().setLocationId(result.getLocationId());
       FetchResult fetchResult = new FetchResult();
       indexManager.fetchRow(TABLE, selector, fetchResult);
@@ -624,7 +633,9 @@ public class IndexManagerTest {
 
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null);
     assertEquals(2, iterable.getTotalResults());
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       Selector selector = new Selector().setLocationId(result.getLocationId());
       FetchResult fetchResult = new FetchResult();
       indexManager.fetchRow(TABLE, selector, fetchResult);
@@ -652,7 +663,9 @@ public class IndexManagerTest {
 
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null);
     assertEquals(iterable.getTotalResults(), 2);
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       assertNotNull(result.fetchResult.rowResult);
       assertNull(result.fetchResult.recordResult);
     }
@@ -675,7 +688,9 @@ public class IndexManagerTest {
 
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null);
     assertEquals(iterable.getTotalResults(), 2);
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       Selector selector = new Selector().setLocationId(result.getLocationId()).setRecordOnly(true);
       FetchResult fetchResult = new FetchResult();
       indexManager.fetchRow(TABLE, selector, fetchResult);
@@ -703,7 +718,9 @@ public class IndexManagerTest {
 
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null);
     assertEquals(iterable.getTotalResults(), 2);
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       assertNull(result.fetchResult.rowResult);
       assertNotNull(result.fetchResult.recordResult);
     }
@@ -727,7 +744,9 @@ public class IndexManagerTest {
     int matchRecord1 = 0;
     int matchRecord4 = 0;
 
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       assertNull(result.fetchResult.rowResult);
       assertNotNull(result.fetchResult.recordResult);
 
@@ -763,7 +782,9 @@ public class IndexManagerTest {
     AtomicLongArray facetedCounts = new AtomicLongArray(2);
     BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, facetedCounts);
     assertEquals(iterable.getTotalResults(), 2);
-    for (BlurResult result : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult result = iterator.next();
       Selector selector = new Selector().setLocationId(result.getLocationId());
       FetchResult fetchResult = new FetchResult();
       indexManager.fetchRow(TABLE, selector, fetchResult);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/test/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparatorTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparatorTest.java b/blur-core/src/test/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparatorTest.java
index 659508c..36386c4 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparatorTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/results/BlurResultPeekableIteratorComparatorTest.java
@@ -20,8 +20,10 @@ package org.apache.blur.manager.results;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.utils.BlurUtil;
 import org.junit.Test;
@@ -30,23 +32,27 @@ import org.junit.Test;
 public class BlurResultPeekableIteratorComparatorTest {
 
   @Test
-  public void testResultPeekableIteratorComparator() {
-    List<PeekableIterator<BlurResult>> results = new ArrayList<PeekableIterator<BlurResult>>();
-    results.add(new PeekableIterator<BlurResult>(new ArrayList<BlurResult>(Arrays.asList(newResult("5", 5))).iterator()));
-    results.add(new PeekableIterator<BlurResult>(new ArrayList<BlurResult>().iterator()));
-    results.add(new PeekableIterator<BlurResult>(new ArrayList<BlurResult>().iterator()));
-    results.add(new PeekableIterator<BlurResult>(new ArrayList<BlurResult>(Arrays.asList(newResult("2", 2))).iterator()));
-    results.add(new PeekableIterator<BlurResult>(new ArrayList<BlurResult>(Arrays.asList(newResult("1", 1))).iterator()));
-    results.add(new PeekableIterator<BlurResult>(new ArrayList<BlurResult>(Arrays.asList(newResult("9", 1))).iterator()));
-    results.add(new PeekableIterator<BlurResult>(new ArrayList<BlurResult>().iterator()));
+  public void testResultPeekableIteratorComparator() throws BlurException {
+    List<PeekableIterator<BlurResult,BlurException>> results = new ArrayList<PeekableIterator<BlurResult,BlurException>>();
+    results.add(PeekableIterator.wrap(wrap(new ArrayList<BlurResult>(Arrays.asList(newResult("5", 5))).iterator())));
+    results.add(PeekableIterator.wrap(wrap(new ArrayList<BlurResult>().iterator())));
+    results.add(PeekableIterator.wrap(wrap(new ArrayList<BlurResult>().iterator())));
+    results.add(PeekableIterator.wrap(wrap(new ArrayList<BlurResult>(Arrays.asList(newResult("2", 2))).iterator())));
+    results.add(PeekableIterator.wrap(wrap(new ArrayList<BlurResult>(Arrays.asList(newResult("1", 1))).iterator())));
+    results.add(PeekableIterator.wrap(wrap(new ArrayList<BlurResult>(Arrays.asList(newResult("9", 1))).iterator())));
+    results.add(PeekableIterator.wrap(wrap(new ArrayList<BlurResult>().iterator())));
 
     Collections.sort(results, BlurUtil.HITS_PEEKABLE_ITERATOR_COMPARATOR);
 
-    for (PeekableIterator<BlurResult> iterator : results) {
+    for (PeekableIterator<BlurResult,BlurException> iterator : results) {
       System.out.println(iterator.peek());
     }
   }
 
+  private BlurIterator<BlurResult, BlurException> wrap(Iterator<BlurResult> iterator) {
+    return BlurUtil.convert(iterator);
+  }
+
   private BlurResult newResult(String id, double score) {
     return new BlurResult(id, score, null);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java b/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java
index 7207eea..70a62df 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/results/MultipleBlurResultIterableTest.java
@@ -24,6 +24,7 @@ import java.util.UUID;
 import org.apache.blur.manager.results.BlurResultIterable;
 import org.apache.blur.manager.results.BlurResultIterableMultiple;
 import org.apache.blur.manager.results.BlurResultIterableSimple;
+import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
 import org.junit.Test;
 
@@ -31,7 +32,7 @@ import org.junit.Test;
 public class MultipleBlurResultIterableTest {
 
   @Test
-  public void testMultipleHitsIterable() {
+  public void testMultipleHitsIterable() throws BlurException {
     BlurResultIterableMultiple iterable = new BlurResultIterableMultiple();
     iterable.addBlurResultIterable(newBlurResultIterable(0, 0.1, 3, 2, 9, 10, 2));
     iterable.addBlurResultIterable(newBlurResultIterable(7, 2, 9, 1, 34, 53, 12));
@@ -39,7 +40,9 @@ public class MultipleBlurResultIterableTest {
     iterable.addBlurResultIterable(newBlurResultIterable(7, 2, 34, 132));
     iterable.addBlurResultIterable(newBlurResultIterable());
 
-    for (BlurResult hit : iterable) {
+    BlurIterator<BlurResult, BlurException> iterator = iterable.iterator();
+    while (iterator.hasNext()) {
+      BlurResult hit = iterator.next();
       System.out.println(hit);
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/test/java/org/apache/blur/manager/results/PeekableIteratorTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/results/PeekableIteratorTest.java b/blur-core/src/test/java/org/apache/blur/manager/results/PeekableIteratorTest.java
index f590ef0..be7c5df 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/results/PeekableIteratorTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/results/PeekableIteratorTest.java
@@ -21,14 +21,15 @@ import java.util.ArrayList;
 import java.util.Arrays;
 
 import org.apache.blur.manager.results.PeekableIterator;
+import org.apache.blur.utils.BlurUtil;
 import org.junit.Test;
 
 
 public class PeekableIteratorTest {
 
   @Test
-  public void testPeekableIterator1() {
-    PeekableIterator<Integer> iterator = new PeekableIterator<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).iterator());
+  public void testPeekableIterator1() throws Exception {
+    PeekableIterator<Integer,Exception> iterator = PeekableIterator.wrap(BlurUtil.convert(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).iterator()));
     while (iterator.hasNext()) {
       for (int i = 0; i < 3; i++) {
         System.out.println(iterator.peek());
@@ -38,8 +39,8 @@ public class PeekableIteratorTest {
   }
 
   @Test
-  public void testPeekableIteratorEmpty() {
-    PeekableIterator<Integer> iterator = new PeekableIterator<Integer>(new ArrayList<Integer>().iterator());
+  public void testPeekableIteratorEmpty() throws Exception {
+    PeekableIterator<Integer,Exception> iterator = PeekableIterator.wrap(BlurUtil.convert(new ArrayList<Integer>().iterator()));
     for (int i = 0; i < 3; i++) {
       System.out.println(iterator.peek());
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java b/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
index 1f51b0b..9399dc5 100644
--- a/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
+++ b/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
@@ -31,6 +31,7 @@ import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.blur.MiniCluster;
+import org.apache.blur.manager.IndexManager;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.Blur.Iface;
@@ -123,6 +124,8 @@ public class BlurClusterTest {
     SimpleQuery simpleQueryRow = new SimpleQuery();
     simpleQueryRow.setQueryStr("test.test:value");
     blurQueryRow.setSimpleQuery(simpleQueryRow);
+    blurQueryRow.setUseCacheIfPresent(false);
+    blurQueryRow.setCacheResult(false);
     BlurResults resultsRow = client.query("test", blurQueryRow);
     assertRowResults(resultsRow);
     assertEquals(length, resultsRow.getTotalResults());
@@ -138,6 +141,45 @@ public class BlurClusterTest {
   }
 
   @Test
+  public void testQueryCancel() throws BlurException, TException, InterruptedException {
+    // This will make each collect in the collectors pause 250 ms per collect call
+    IndexManager.DEBUG_RUN_SLOW.set(true);
+    
+    final Iface client = getClient();
+    final BlurQuery blurQueryRow = new BlurQuery();
+    SimpleQuery simpleQueryRow = new SimpleQuery();
+    simpleQueryRow.setQueryStr("test.test:value");
+    blurQueryRow.setSimpleQuery(simpleQueryRow);
+    blurQueryRow.setUseCacheIfPresent(false);
+    blurQueryRow.setCacheResult(false);
+    blurQueryRow.setUuid(1234l);
+    
+    new Thread(new Runnable() {
+      @Override
+      public void run() {
+//        int length = 100;
+        
+        BlurResults resultsRow;
+        try {
+          // This call will take several seconds to execute.
+          resultsRow = client.query("test", blurQueryRow);
+        } catch (BlurException e) {
+          System.out.println("error " + e);
+        } catch (TException e) {
+          e.printStackTrace();
+        }
+//        assertRowResults(resultsRow);
+//        assertEquals(length, resultsRow.getTotalResults());    
+      }
+    }).start();
+    
+    Thread.sleep(500);
+    
+    client.cancelQuery("test", blurQueryRow.getUuid());
+
+  }
+
+  @Test
   public void testTestShardFailover() throws BlurException, TException, InterruptedException, IOException,
       KeeperException {
     Iface client = getClient();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java
----------------------------------------------------------------------
diff --git a/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java b/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java
index 4edfb6b..413c0d8 100644
--- a/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java
+++ b/blur-mapred/src/main/java/org/apache/blur/mapreduce/BlurReducer.java
@@ -27,6 +27,7 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -51,8 +52,6 @@ import org.apache.blur.thrift.generated.Selector;
 import org.apache.blur.thrift.generated.TableDescriptor;
 import org.apache.blur.utils.BlurConstants;
 import org.apache.blur.utils.BlurUtil;
-import org.apache.blur.utils.Converter;
-import org.apache.blur.utils.IterableConverter;
 import org.apache.blur.utils.ResetableDocumentStoredFieldVisitor;
 import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.conf.Configuration;
@@ -474,14 +473,31 @@ public class BlurReducer extends Reducer<Text, BlurMutate, Text, BlurMutate> {
     document.add(new Field(BlurConstants.RECORD_ID, record.getRecordId(), TransactionRecorder.ID_TYPE));
 
     String columnFamily = record.getFamily();
-    TransactionRecorder.addColumns(document, _analyzer, columnFamily, new IterableConverter<BlurColumn, Column>(
-        record.getColumns(), new Converter<BlurColumn, Column>() {
+    List<BlurColumn> columns = record.getColumns();
+    final Iterator<BlurColumn> iterator = columns.iterator();
+    TransactionRecorder.addColumns(document, _analyzer, columnFamily, new Iterable<Column>() {
+      @Override
+      public Iterator<Column> iterator() {
+        return new Iterator<Column>() {
+
           @Override
-          public Column convert(BlurColumn from) throws Exception {
-            _fieldCounter.increment(1);
-            return new Column(from.getName(), from.getValue());
+          public Column next() {
+            BlurColumn bc = iterator.next();
+            return new Column(bc.getName(), bc.getValue());
           }
-        }));
+
+          @Override
+          public boolean hasNext() {
+            return iterator.hasNext();
+          }
+
+          @Override
+          public void remove() {
+
+          }
+        };
+      }
+    });
     return document;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java b/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java
index 586b68a..1112b3c 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java
@@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.lucene.search.Collector;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
@@ -37,6 +38,7 @@ public class IterablePaging implements Iterable<ScoreDoc> {
   private final Query query;
   private final AtomicBoolean running;
   private final int numHitsToCollect;
+  private final boolean _runSlow;
 
   private TotalHitsRef totalHitsRef;
   private ProgressRef progressRef;
@@ -44,14 +46,14 @@ public class IterablePaging implements Iterable<ScoreDoc> {
   private int gather = -1;
 
   public IterablePaging(AtomicBoolean running, IndexSearcher searcher, Query query,
-      int numHitsToCollect, TotalHitsRef totalHitsRef, ProgressRef progressRef) throws IOException {
+      int numHitsToCollect, TotalHitsRef totalHitsRef, ProgressRef progressRef, boolean runSlow) throws IOException {
     this.running = running;
     this.query = searcher.rewrite(query);
     this.searcher = searcher;
     this.numHitsToCollect = numHitsToCollect;
     this.totalHitsRef = totalHitsRef == null ? new TotalHitsRef() : totalHitsRef;
     this.progressRef = progressRef == null ? new ProgressRef() : progressRef;
-
+    _runSlow = runSlow;
   }
 
   public static class TotalHitsRef {
@@ -170,8 +172,11 @@ public class IterablePaging implements Iterable<ScoreDoc> {
       progressRef.searchesPerformed.incrementAndGet();
       try {
         TopScoreDocCollector collector = TopScoreDocCollector.create(numHitsToCollect, lastScoreDoc, true);
-        StopExecutionCollector stopExecutionCollector = new StopExecutionCollector(collector, running);
-        searcher.search(query, stopExecutionCollector);
+        Collector col = new StopExecutionCollector(collector, running);
+        if (_runSlow) {
+          col = new SlowCollector(col);
+        }
+        searcher.search(query, col);
         totalHitsRef.totalHits.set(collector.getTotalHits());
         TopDocs topDocs = collector.topDocs();
         scoreDocs = topDocs.scoreDocs;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/main/java/org/apache/blur/lucene/search/SlowCollector.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/SlowCollector.java b/blur-query/src/main/java/org/apache/blur/lucene/search/SlowCollector.java
new file mode 100644
index 0000000..f3e2c64
--- /dev/null
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/SlowCollector.java
@@ -0,0 +1,60 @@
+package org.apache.blur.lucene.search;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.Scorer;
+
+public class SlowCollector extends Collector {
+
+  private static final long DELAY = TimeUnit.MILLISECONDS.toMillis(250);
+  private Collector _collector;
+
+  public SlowCollector(Collector collector) {
+    _collector = collector;
+  }
+
+  @Override
+  public void setScorer(Scorer scorer) throws IOException {
+    _collector.setScorer(scorer);
+  }
+
+  @Override
+  public void collect(int doc) throws IOException {
+    _collector.collect(doc);
+    try {
+      Thread.sleep(DELAY);
+    } catch (InterruptedException e) {
+      return;
+    }
+  }
+
+  @Override
+  public void setNextReader(AtomicReaderContext context) throws IOException {
+    _collector.setNextReader(context);
+  }
+
+  @Override
+  public boolean acceptsDocsOutOfOrder() {
+    return _collector.acceptsDocsOutOfOrder();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/main/java/org/apache/blur/lucene/search/SuperQuery.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/SuperQuery.java b/blur-query/src/main/java/org/apache/blur/lucene/search/SuperQuery.java
index f3cee51..a25e926 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/SuperQuery.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/SuperQuery.java
@@ -18,6 +18,7 @@ package org.apache.blur.lucene.search;
  */
 import java.io.IOException;
 
+import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
@@ -28,7 +29,6 @@ import org.apache.lucene.search.Scorer;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.OpenBitSet;
-import org.apache.blur.thrift.generated.ScoreType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/main/java/org/apache/blur/lucene/serializer/ProtoSerializer.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/serializer/ProtoSerializer.java b/blur-query/src/main/java/org/apache/blur/lucene/serializer/ProtoSerializer.java
index 37ac3a4..0a1be9f 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/serializer/ProtoSerializer.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/serializer/ProtoSerializer.java
@@ -18,8 +18,8 @@ package org.apache.blur.lucene.serializer;
  */
 import java.io.IOException;
 
-import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.blur.lucene.search.SuperQuery;
+import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/main/java/org/apache/blur/lucene/serializer/SuperQueryWritable.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/serializer/SuperQueryWritable.java b/blur-query/src/main/java/org/apache/blur/lucene/serializer/SuperQueryWritable.java
index 12f695a..d9f0b69 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/serializer/SuperQueryWritable.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/serializer/SuperQueryWritable.java
@@ -20,8 +20,8 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 
-import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.blur.lucene.search.SuperQuery;
+import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Query;
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/test/java/org/apache/blur/lucene/search/FacetQueryTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/FacetQueryTest.java b/blur-query/src/test/java/org/apache/blur/lucene/search/FacetQueryTest.java
index fadd0d5..f0f7cd7 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/FacetQueryTest.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/FacetQueryTest.java
@@ -17,6 +17,8 @@ package org.apache.blur.lucene.search;
  * limitations under the License.
  */
 
+import static org.apache.blur.lucene.LuceneVersionConstant.LUCENE_VERSION;
+
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicLongArray;
 
@@ -37,7 +39,6 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.store.RAMDirectory;
-import static org.apache.blur.lucene.LuceneVersionConstant.LUCENE_VERSION;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/test/java/org/apache/blur/lucene/search/RandomSuperQueryTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/RandomSuperQueryTest.java b/blur-query/src/test/java/org/apache/blur/lucene/search/RandomSuperQueryTest.java
index ceaca80..25d860d 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/RandomSuperQueryTest.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/RandomSuperQueryTest.java
@@ -30,7 +30,6 @@ import java.util.Map;
 import java.util.Random;
 
 import org.apache.blur.thrift.generated.ScoreType;
-import org.apache.blur.lucene.search.SuperQuery;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field.Store;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/test/java/org/apache/blur/lucene/search/SuperQueryTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperQueryTest.java b/blur-query/src/test/java/org/apache/blur/lucene/search/SuperQueryTest.java
index 37346c9..54ee490 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/SuperQueryTest.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/SuperQueryTest.java
@@ -25,8 +25,6 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicLongArray;
 
-import org.apache.blur.lucene.search.FacetQuery;
-import org.apache.blur.lucene.search.SuperQuery;
 import org.apache.blur.thrift.generated.ScoreType;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/7a01385e/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java b/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
index 9358eb2..636b6cb 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
@@ -21,7 +21,6 @@ import static org.apache.blur.lucene.LuceneVersionConstant.LUCENE_VERSION;
 
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.blur.lucene.search.IterablePaging;
 import org.apache.blur.lucene.search.IterablePaging.ProgressRef;
 import org.apache.blur.lucene.search.IterablePaging.TotalHitsRef;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
@@ -42,7 +41,6 @@ import org.junit.Test;
 /**
  * Testing the paging collector.
  * 
- * @author Aaron McCurry
  */
 public class TestingPagingCollector {
 
@@ -59,7 +57,7 @@ public class TestingPagingCollector {
     ProgressRef progressRef = new ProgressRef();
 
     TermQuery query = new TermQuery(new Term("f1", "value"));
-    IterablePaging paging = new IterablePaging(new AtomicBoolean(true), searcher, query, 100, null, null);
+    IterablePaging paging = new IterablePaging(new AtomicBoolean(true), searcher, query, 100, null, null, false);
 
     for (ScoreDoc sd : paging.skipTo(90).gather(20).totalHits(totalHitsRef).progress(progressRef)) {
 


Mime
View raw message