incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/7] git commit: Inital commit to fixing a long time lucene raw id changing during mutation issue.
Date Wed, 22 May 2013 23:46:29 GMT
Updated Branches:
  refs/heads/0.1.5 d61255c6b -> 51aa6d099


Inital commit to fixing a long time lucene raw id changing during mutation issue.


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

Branch: refs/heads/0.1.5
Commit: 557f187232cc5cf339c0896b4c14fba3726af066
Parents: 5fd0a0f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun May 19 14:54:54 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun May 19 14:54:54 2013 -0400

----------------------------------------------------------------------
 .../java/org/apache/blur/manager/IndexManager.java |   56 +++++---
 .../results/BlurResultIterableSearcher.java        |   16 +-
 .../org/apache/blur/server/ShardServerContext.java |  126 +++++++++++++++
 .../blur/server/ShardServerEventHandler.java       |   28 +++-
 .../org/apache/blur/thrift/BlurShardServer.java    |   20 +++
 .../org/apache/blur/thrift/BlurClusterTest.java    |    6 +
 .../apache/blur/testsuite/SimpleQueryExample.java  |   10 ++
 7 files changed, 234 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/557f1872/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
index ab40d9e..3483a54 100644
--- a/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
+++ b/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
@@ -57,6 +57,7 @@ import org.apache.blur.manager.status.QueryStatus;
 import org.apache.blur.manager.status.QueryStatusManager;
 import org.apache.blur.manager.writer.BlurIndex;
 import org.apache.blur.server.IndexSearcherClosable;
+import org.apache.blur.server.ShardServerContext;
 import org.apache.blur.server.TableContext;
 import org.apache.blur.thrift.BException;
 import org.apache.blur.thrift.MutationHelper;
@@ -171,8 +172,11 @@ public class IndexManager {
   public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException
{
     validSelector(selector);
     BlurIndex index;
+    String shard;
     try {
       if (selector.getLocationId() == null) {
+        //Not looking up by location id so we should resetSearchers.
+        ShardServerContext.resetSearchers();
         populateSelector(table, selector);
       }
       String locationId = selector.getLocationId();
@@ -181,7 +185,7 @@ public class IndexManager {
         fetchResult.setExists(false);
         return;
       }
-      String shard = getShard(locationId);
+      shard = getShard(locationId);
       Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table);
       if (blurIndexes == null) {
         LOG.error("Table [{0}] not found", table);
@@ -189,10 +193,8 @@ public class IndexManager {
       }
       index = blurIndexes.get(shard);
       if (index == null) {
-        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);
-        }
+        LOG.error("Shard [{0}] not found in table [{1}]", shard, table);
+        throw new BlurException("Shard [" + shard + "] not found in table [" + table + "]",
null);
       }
     } catch (BlurException e) {
       throw e;
@@ -202,8 +204,17 @@ public class IndexManager {
     }
     IndexSearcherClosable searcher = null;
     TimerContext timerContext = _fetchTimer.time();
+    boolean usedCache = true;
     try {
-      searcher = index.getIndexReader();
+      ShardServerContext shardServerContext = ShardServerContext.getShardServerContext();
+      if (shardServerContext != null) {
+        searcher = shardServerContext.getIndexSearcherClosable(table, shard);
+      }
+      if (searcher == null) {
+        searcher = index.getIndexReader();
+        usedCache = false;
+      }
+
       fetchRow(searcher.getIndexReader(), table, selector, fetchResult);
       if (fetchResult.rowResult != null) {
         if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records
!= null) {
@@ -218,7 +229,8 @@ public class IndexManager {
       throw new BException(e.getMessage(), e);
     } finally {
       timerContext.stop();
-      if (searcher != null) {
+      if (!usedCache && searcher != null) {
+        // if the cached search was not used, close the searcher.
         // this will allow for closing of index
         try {
           searcher.close();
@@ -326,6 +338,7 @@ public class IndexManager {
         LOG.error("Unknown error while trying to fetch index readers.", e);
         throw new BException(e.getMessage(), e);
       }
+      ShardServerContext shardServerContext = ShardServerContext.getShardServerContext();
       BlurAnalyzer analyzer = _indexServer.getAnalyzer(table);
       ParallelCall<Entry<String, BlurIndex>, BlurResultIterable> call;
       TableContext context = getTableContext(table);
@@ -339,7 +352,7 @@ public class IndexManager {
             postFilter, preFilter, getScoreType(simpleQuery.type), context);
         Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer,
context);
         call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery,
blurQuery.selector,
-            _queriesInternalMeter);
+            _queriesInternalMeter, shardServerContext);
       } else {
         Query query = getQuery(blurQuery.expertQuery);
         Filter filter = getFilter(blurQuery.expertQuery);
@@ -351,7 +364,7 @@ public class IndexManager {
         }
         Query facetedQuery = getFacetedQuery(blurQuery, userQuery, facetedCounts, analyzer,
context);
         call = new SimpleQueryParallelCall(running, table, status, _indexServer, facetedQuery,
blurQuery.selector,
-            _queriesInternalMeter);
+            _queriesInternalMeter, shardServerContext);
       }
       MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery);
       return ForkJoin.execute(_executor, blurIndexes.entrySet(), call, new Cancel() {
@@ -944,16 +957,17 @@ public class IndexManager {
 
   public static class SimpleQueryParallelCall implements ParallelCall<Entry<String,
BlurIndex>, BlurResultIterable> {
 
-    private String _table;
-    private QueryStatus _status;
-    private IndexServer _indexServer;
-    private Query _query;
-    private Selector _selector;
-    private AtomicBoolean _running;
-    private Meter _queriesInternalMeter;
+    private final String _table;
+    private final QueryStatus _status;
+    private final IndexServer _indexServer;
+    private final Query _query;
+    private final Selector _selector;
+    private final AtomicBoolean _running;
+    private final Meter _queriesInternalMeter;
+    private final ShardServerContext _shardServerContext;
 
     public SimpleQueryParallelCall(AtomicBoolean running, String table, QueryStatus status,
IndexServer indexServer,
-        Query query, Selector selector, Meter queriesInternalMeter) {
+        Query query, Selector selector, Meter queriesInternalMeter, ShardServerContext shardServerContext)
{
       _running = running;
       _table = table;
       _status = status;
@@ -961,6 +975,7 @@ public class IndexManager {
       _query = query;
       _selector = selector;
       _queriesInternalMeter = queriesInternalMeter;
+      _shardServerContext = shardServerContext;
     }
 
     @Override
@@ -973,11 +988,14 @@ public class IndexManager {
         // @TODO need to add escapable rewriter
         // IndexReader escapeReader = EscapeRewrite.wrap(reader, _running);
         // IndexSearcher searcher = new IndexSearcher(escapeReader);
+        if (_shardServerContext != null) {
+          _shardServerContext.setIndexSearcherClosable(_table, shard, searcher);
+        }
         searcher.setSimilarity(_indexServer.getSimilarity(_table));
         Query rewrite = searcher.rewrite((Query) _query.clone());
 
-        // BlurResultIterableSearcher will close searcher.
-        return new BlurResultIterableSearcher(_running, rewrite, _table, shard, searcher,
_selector);
+        // BlurResultIterableSearcher will close searcher, if shard server context is null.
+        return new BlurResultIterableSearcher(_running, rewrite, _table, shard, searcher,
_selector, _shardServerContext == null);
       } finally {
         _queriesInternalMeter.mark();
         _status.deattachThread();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/557f1872/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
b/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
index 8f245ac..882411d 100644
--- a/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
+++ b/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
@@ -46,14 +46,15 @@ public class BlurResultIterableSearcher implements BlurResultIterable
{
   private int _fetchCount = 1000;
 
   private IteratorConverter<ScoreDoc, BlurResult> _iterator;
-  private Selector _selector;
-  private Query _query;
+  private final Selector _selector;
+  private final Query _query;
   private IndexSearcherClosable _searcher;
-  private TotalHitsRef _totalHitsRef = new TotalHitsRef();
-  private ProgressRef _progressRef = new ProgressRef();
-  private AtomicBoolean _running;
+  private final TotalHitsRef _totalHitsRef = new TotalHitsRef();
+  private final ProgressRef _progressRef = new ProgressRef();
+  private final AtomicBoolean _running;
+  private final boolean _closeSearcher;
 
-  public BlurResultIterableSearcher(AtomicBoolean running, Query query, String table, String
shard, IndexSearcherClosable searcher, Selector selector)
+  public BlurResultIterableSearcher(AtomicBoolean running, Query query, String table, String
shard, IndexSearcherClosable searcher, Selector selector, boolean closeSearcher)
       throws IOException {
     _running = running;
     _table = table;
@@ -61,6 +62,7 @@ public class BlurResultIterableSearcher implements BlurResultIterable {
     _shard = shard;
     _searcher = searcher;
     _selector = selector;
+    _closeSearcher = closeSearcher;
     performSearch();
   }
 
@@ -118,7 +120,7 @@ public class BlurResultIterableSearcher implements BlurResultIterable
{
 
   @Override
   public void close() throws IOException {
-    if (_searcher != null) {
+    if (_searcher != null && _closeSearcher) {
       _searcher.close();
       _searcher = null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/557f1872/src/blur-core/src/main/java/org/apache/blur/server/ShardServerContext.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/server/ShardServerContext.java b/src/blur-core/src/main/java/org/apache/blur/server/ShardServerContext.java
index 3d27cae..b6af900 100644
--- a/src/blur-core/src/main/java/org/apache/blur/server/ShardServerContext.java
+++ b/src/blur-core/src/main/java/org/apache/blur/server/ShardServerContext.java
@@ -1,7 +1,133 @@
 package org.apache.blur.server;
 
+/**
+ * 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.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.blur.log.Log;
+import org.apache.blur.log.LogFactory;
+import org.apache.hadoop.io.IOUtils;
 import org.apache.thrift.server.ServerContext;
 
+/**
+ * The thrift session that will hold index reader references to maintain across
+ * query and fetch calls. Since there is a fixed size thread pool issuing calls
+ * that involve the _threadsToContext map where Thread is the key we don't need
+ * to clear or reset threads.
+ */
 public class ShardServerContext implements ServerContext {
 
+  private static final Log LOG = LogFactory.getLog(ShardServerContext.class);
+
+  private final static Map<Thread, ShardServerContext> _threadsToContext = new ConcurrentHashMap<Thread,
ShardServerContext>();
+  private final Map<String, IndexSearcherClosable> _indexSearcherMap = new HashMap<String,
IndexSearcherClosable>();
+
+  /**
+   * Registers the {@link ShardServerContext} for this thread.
+   * 
+   * @param context
+   *          the {@link ShardServerContext}.
+   */
+  public static void registerContextForCall(ShardServerContext context) {
+    _threadsToContext.put(Thread.currentThread(), context);
+  }
+
+  /**
+   * Gets the {@link ShardServerContext} for this {@link Thread}.
+   * 
+   * @return the {@link ShardServerContext}.
+   */
+  public static ShardServerContext getShardServerContext() {
+    return _threadsToContext.get(Thread.currentThread());
+  }
+
+  /**
+   * Resets the context, this closes and releases the index readers.
+   */
+  public static void resetSearchers() {
+    ShardServerContext shardServerContext = getShardServerContext();
+    if (shardServerContext != null) {
+      shardServerContext.reset();
+    }
+  }
+
+  /**
+   * Closes this context, this happens when the client closes it's connect to
+   * the server.
+   */
+  public void close() {
+    reset();
+  }
+
+  /**
+   * Resets the {@link ShardServerContext} by closing the searchers.
+   */
+  public void reset() {
+    Collection<IndexSearcherClosable> values = _indexSearcherMap.values();
+    for (IndexSearcherClosable indexSearcherClosable : values) {
+      LOG.info("Closing [{0}]", indexSearcherClosable);
+      IOUtils.cleanup(LOG, indexSearcherClosable);
+    }
+    _indexSearcherMap.clear();
+  }
+
+  /**
+   * Gets the cached {@link IndexSearcherClosable} (if any) for the given table
+   * and shard.
+   * 
+   * @param table
+   *          the stable name.
+   * @param shard
+   *          the shard name.
+   * @return the {@link IndexSearcherClosable} or null if not present.
+   */
+  public IndexSearcherClosable getIndexSearcherClosable(String table, String shard) {
+    IndexSearcherClosable indexSearcherClosable = _indexSearcherMap.get(getKey(table, shard));
+    if (indexSearcherClosable != null) {
+      LOG.info("Using cached searcher [{0}] for table [{1}] shard [{2}]", indexSearcherClosable,
table, shard);
+    }
+    return indexSearcherClosable;
+  }
+
+  /**
+   * Sets the index searcher for this {@link ShardServerContext} for the given
+   * table and shard.
+   * 
+   * @param table
+   *          the table name.
+   * @param shard
+   *          the shard name.
+   * @param searcher
+   *          the {@link IndexSearcherClosable}.
+   * @throws IOException
+   */
+  public void setIndexSearcherClosable(String table, String shard, IndexSearcherClosable
searcher) throws IOException {
+    IndexSearcherClosable indexSearcherClosable = _indexSearcherMap.put(getKey(table, shard),
searcher);
+    if (indexSearcherClosable != null && searcher != indexSearcherClosable) {
+      indexSearcherClosable.close();
+    }
+  }
+
+  private String getKey(String table, String shard) {
+    return table + "/" + shard;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/557f1872/src/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
b/src/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
index e20129e..df2b47a 100644
--- a/src/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
+++ b/src/blur-core/src/main/java/org/apache/blur/server/ShardServerEventHandler.java
@@ -1,5 +1,21 @@
 package org.apache.blur.server;
 
+/**
+ * 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 org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
 import org.apache.thrift.protocol.TProtocol;
@@ -7,13 +23,17 @@ import org.apache.thrift.server.ServerContext;
 import org.apache.thrift.server.TServerEventHandler;
 import org.apache.thrift.transport.TTransport;
 
+/**
+ * {@link ShardServerContext} is the session manager for the shard servers. It
+ * allows for reader reuse across method calls.
+ */
 public class ShardServerEventHandler implements TServerEventHandler {
-  
+
   private static final Log LOG = LogFactory.getLog(ShardServerEventHandler.class);
 
   @Override
   public void preServe() {
-LOG.info("setup");
+    LOG.info("preServe");
   }
 
   @Override
@@ -25,11 +45,15 @@ LOG.info("setup");
   @Override
   public void deleteContext(ServerContext serverContext, TProtocol input, TProtocol output)
{
     LOG.info("Client disconnected");
+    ShardServerContext context = (ShardServerContext) serverContext;
+    context.close();
   }
 
   @Override
   public void processContext(ServerContext serverContext, TTransport inputTransport, TTransport
outputTransport) {
     LOG.info("Method called");
+    ShardServerContext context = (ShardServerContext) serverContext;
+    ShardServerContext.registerContextForCall(context);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/557f1872/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java b/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java
index 62e6ac3..8a199fd 100644
--- a/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java
+++ b/src/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java
@@ -39,6 +39,7 @@ import org.apache.blur.manager.IndexManager;
 import org.apache.blur.manager.IndexServer;
 import org.apache.blur.manager.results.BlurResultIterable;
 import org.apache.blur.manager.writer.BlurIndex;
+import org.apache.blur.server.ShardServerContext;
 import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
@@ -87,6 +88,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   @Override
   public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, TException
{
     checkTable(_cluster, table);
+    resetSearchers();
     _queryChecker.checkQuery(blurQuery);
     try {
       BlurQuery original = new BlurQuery(blurQuery);
@@ -138,6 +140,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   @Override
   public void cancelQuery(String table, long uuid) throws BlurException, TException {
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       _indexManager.cancelQuery(table, uuid);
     } catch (Exception e) {
@@ -146,9 +149,14 @@ public class BlurShardServer extends TableAdmin implements Iface {
     }
   }
 
+  private void resetSearchers() {
+    ShardServerContext.resetSearchers();
+  }
+
   @Override
   public List<BlurQueryStatus> currentQueries(String table) throws BlurException, TException
{
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       return _indexManager.currentQueries(table);
     } catch (Exception e) {
@@ -160,6 +168,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   @Override
   public TableStats tableStats(String table) throws BlurException, TException {
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       TableStats tableStats = new TableStats();
       tableStats.tableName = table;
@@ -185,6 +194,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   @Override
   public Map<String, String> shardServerLayout(String table) throws BlurException,
TException {
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table);
       Map<String, String> result = new TreeMap<String, String>();
@@ -204,6 +214,8 @@ public class BlurShardServer extends TableAdmin implements Iface {
 
   @Override
   public Map<String, Map<String, ShardState>> shardServerLayoutState(String table)
throws BlurException, TException {
+    checkTable(_cluster, table);
+    resetSearchers();
     try {
       Map<String, Map<String, ShardState>> result = new TreeMap<String, Map<String,
ShardState>>();
       String nodeName = _indexServer.getNodeName();
@@ -231,6 +243,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   public long recordFrequency(String table, String columnFamily, String columnName, String
value) throws BlurException,
       TException {
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       return _indexManager.recordFrequency(table, columnFamily, columnName, value);
     } catch (Exception e) {
@@ -244,6 +257,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   @Override
   public Schema schema(String table) throws BlurException, TException {
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       return _indexManager.schema(table);
     } catch (Exception e) {
@@ -256,6 +270,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   public List<String> terms(String table, String columnFamily, String columnName, String
startWith, short size)
       throws BlurException, TException {
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       return _indexManager.terms(table, columnFamily, columnName, startWith, size);
     } catch (Exception e) {
@@ -270,6 +285,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   public void mutate(RowMutation mutation) throws BlurException, TException {
     checkTable(_cluster, mutation.table);
     checkForUpdates(_cluster, mutation.table);
+    resetSearchers();
     MutationHelper.validateMutation(mutation);
     try {
       _indexManager.mutate(mutation);
@@ -281,6 +297,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
 
   @Override
   public void mutateBatch(List<RowMutation> mutations) throws BlurException, TException
{
+    resetSearchers();
     long s = System.nanoTime();
     for (RowMutation mutation : mutations) {
       checkTable(_cluster, mutation.table);
@@ -328,6 +345,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   @Override
   public BlurQueryStatus queryStatusById(String table, long uuid) throws BlurException, TException
{
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       return _indexManager.queryStatus(table, uuid);
     } catch (Exception e) {
@@ -339,6 +357,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   @Override
   public List<Long> queryStatusIdList(String table) throws BlurException, TException
{
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       return _indexManager.queryStatusIdList(table);
     } catch (Exception e) {
@@ -350,6 +369,7 @@ public class BlurShardServer extends TableAdmin implements Iface {
   @Override
   public void optimize(String table, int numberOfSegmentsPerShard) throws BlurException,
TException {
     checkTable(_cluster, table);
+    resetSearchers();
     try {
       _indexManager.optimize(table, numberOfSegmentsPerShard);
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/557f1872/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java b/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
index 6aaa236..8b00010 100644
--- a/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
+++ b/src/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
@@ -136,8 +136,14 @@ public class BlurClusterTest {
     
     MiniCluster.killShardServer(1);
     
+    //This should block until shards have failed over
     client.shardServerLayout("test");
     
+    for (int i = 0; i < 40; i++) {
+      System.out.println(client.query("test", blurQuery).getTotalResults());
+      Thread.sleep(1000);
+    }
+    
     assertEquals(length, client.query("test", blurQuery).getTotalResults());
     
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/557f1872/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SimpleQueryExample.java
----------------------------------------------------------------------
diff --git a/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SimpleQueryExample.java
b/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SimpleQueryExample.java
index df16bd8..f6395dc 100644
--- a/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SimpleQueryExample.java
+++ b/src/blur-testsuite/src/main/java/org/apache/blur/testsuite/SimpleQueryExample.java
@@ -22,7 +22,10 @@ import org.apache.blur.thrift.BlurClient;
 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;
+import org.apache.blur.thrift.generated.FetchResult;
+import org.apache.blur.thrift.generated.Selector;
 import org.apache.blur.thrift.generated.SimpleQuery;
 import org.apache.thrift.TException;
 
@@ -41,5 +44,12 @@ public class SimpleQueryExample {
     simpleQuery.setQueryStr(query);
     BlurResults results = client.query(tableName, blurQuery);
     System.out.println("Total Results: " + results.totalResults);
+    
+    for (BlurResult result : results.getResults()) {
+      String locationId = result.getLocationId();
+      System.out.println(locationId);
+      FetchResult fetchRow = client.fetchRow(tableName, new Selector().setLocationId(locationId));
+      System.out.println(fetchRow);
+    }
   }
 }


Mime
View raw message