incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [4/51] [partial] Initial repackage to org.apache.
Date Mon, 03 Sep 2012 03:17:10 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/indexserver/DistributedLayoutManager.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/indexserver/DistributedLayoutManager.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/indexserver/DistributedLayoutManager.java
deleted file mode 100644
index eafe297..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/indexserver/DistributedLayoutManager.java
+++ /dev/null
@@ -1,245 +0,0 @@
-package com.nearinfinity.blur.manager.indexserver;
-
-/**
- * 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.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.Map.Entry;
-
-public class DistributedLayoutManager {
-
-  private static final SortedSet<String> EMPTY_SORTED_SET = new TreeSet<String>();
-
-  private SortedSet<String> nodes = EMPTY_SORTED_SET;
-  private Set<String> nodesOffline = EMPTY_SORTED_SET;
-  private SortedSet<String> shards = EMPTY_SORTED_SET;
-  private List<String> nodeList = new ArrayList<String>();
-  private Map<String, String> cache = new TreeMap<String, String>();
-
-  public DistributedLayoutManager init() {
-    if (nodesOffline.equals(nodes) || nodes.isEmpty()) {
-      cache = getLockedMap(new TreeMap<String, String>());
-      return this;
-    }
-    Map<String, String> mappings = new TreeMap<String, String>();
-    SortedSet<String> moveBecauseOfDownNodes = new TreeSet<String>();
-    int nodeListSize = nodeList.size();
-    int nodeCount = getStartingPoint();
-    for (String shard : shards) {
-      String node = nodeList.get(nodeCount);
-      mappings.put(shard, node);
-      if (nodesOffline.contains(node)) {
-        moveBecauseOfDownNodes.add(shard);
-      }
-      nodeCount++;
-      if (nodeCount >= nodeListSize) {
-        nodeCount = 0;
-      }
-    }
-    for (String shard : moveBecauseOfDownNodes) {
-      String node = nodeList.get(nodeCount);
-      while (isOffline(node)) {
-        nodeCount++;
-        if (nodeCount >= nodeListSize) {
-          nodeCount = 0;
-        }
-        node = nodeList.get(nodeCount);
-      }
-      mappings.put(shard, node);
-      nodeCount++;
-      if (nodeCount >= nodeListSize) {
-        nodeCount = 0;
-      }
-    }
-    cache = getLockedMap(mappings);
-    return this;
-  }
-
-  private int getStartingPoint() {
-    int size = nodes.size();
-    int hash = 37;
-    for (String node : nodes) {
-      hash += node.hashCode() * 17;
-    }
-    return Math.abs(hash % size);
-  }
-
-  public Map<String, String> getLayout() {
-    return cache;
-  }
-
-  private boolean isOffline(String node) {
-    return nodesOffline.contains(node);
-  }
-
-  public Collection<String> getNodes() {
-    return new TreeSet<String>(nodes);
-  }
-
-  public void setNodes(Collection<String> v) {
-    this.nodes = new TreeSet<String>(v);
-    this.nodeList = new ArrayList<String>(nodes);
-  }
-
-  public Collection<String> getShards() {
-    return new TreeSet<String>(shards);
-  }
-
-  public void setShards(Collection<String> v) {
-    this.shards = new TreeSet<String>(v);
-  }
-
-  public Collection<String> getNodesOffline() {
-    return new TreeSet<String>(nodesOffline);
-  }
-
-  public void setNodesOffline(Collection<String> v) {
-    this.nodesOffline = new HashSet<String>(v);
-  }
-
-  private Map<String, String> getLockedMap(final Map<String, String> map) {
-    final Set<Entry<String, String>> entrySet = wrapEntries(map.entrySet());
-    return new Map<String, String>() {
-
-      @Override
-      public boolean containsKey(Object key) {
-        return map.containsKey(key);
-      }
-
-      @Override
-      public boolean containsValue(Object value) {
-        return map.containsValue(value);
-      }
-
-      @Override
-      public Set<java.util.Map.Entry<String, String>> entrySet() {
-        return entrySet;
-      }
-
-      @Override
-      public String get(Object key) {
-        return map.get(key);
-      }
-
-      @Override
-      public boolean isEmpty() {
-        return map.isEmpty();
-      }
-
-      @Override
-      public Set<String> keySet() {
-        return new TreeSet<String>(map.keySet());
-      }
-
-      @Override
-      public int size() {
-        return map.size();
-      }
-
-      @Override
-      public Collection<String> values() {
-        return new TreeSet<String>(map.values());
-      }
-
-      @Override
-      public void clear() {
-        throw new RuntimeException("read only");
-      }
-
-      @Override
-      public String put(String key, String value) {
-        throw new RuntimeException("read only");
-      }
-
-      @Override
-      public void putAll(Map<? extends String, ? extends String> m) {
-        throw new RuntimeException("read only");
-      }
-
-      @Override
-      public String remove(Object key) {
-        throw new RuntimeException("read only");
-      }
-
-      @Override
-      public String toString() {
-        return map.toString();
-      }
-
-      @Override
-      public boolean equals(Object obj) {
-        return map.equals(obj);
-      }
-
-      @Override
-      public int hashCode() {
-        return map.hashCode();
-      }
-    };
-  }
-
-  private Set<Entry<String, String>> wrapEntries(Set<Entry<String, String>> entrySet) {
-    Set<Entry<String, String>> result = new HashSet<Entry<String, String>>();
-    for (Entry<String, String> entry : entrySet) {
-      result.add(wrapEntry(entry));
-    }
-    return result;
-  }
-
-  private Entry<String, String> wrapEntry(final Entry<String, String> entry) {
-    return new Entry<String, String>() {
-
-      @Override
-      public String setValue(String value) {
-        throw new RuntimeException("read only");
-      }
-
-      @Override
-      public String getValue() {
-        return entry.getValue();
-      }
-
-      @Override
-      public String getKey() {
-        return entry.getKey();
-      }
-
-      @Override
-      public String toString() {
-        return entry.toString();
-      }
-
-      @Override
-      public boolean equals(Object obj) {
-        return entry.equals(obj);
-      }
-
-      @Override
-      public int hashCode() {
-        return entry.hashCode();
-      }
-    };
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/indexserver/LocalIndexServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/indexserver/LocalIndexServer.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/indexserver/LocalIndexServer.java
deleted file mode 100644
index 2a6bae9..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/indexserver/LocalIndexServer.java
+++ /dev/null
@@ -1,229 +0,0 @@
-package com.nearinfinity.blur.manager.indexserver;
-
-/**
- * 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 static com.nearinfinity.blur.lucene.LuceneConstant.LUCENE_VERSION;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.compress.CompressionCodec;
-import org.apache.lucene.analysis.KeywordAnalyzer;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MMapDirectory;
-
-import com.nearinfinity.blur.analysis.BlurAnalyzer;
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.lucene.search.FairSimilarity;
-import com.nearinfinity.blur.manager.writer.BlurIndex;
-import com.nearinfinity.blur.manager.writer.BlurIndexCloser;
-import com.nearinfinity.blur.manager.writer.BlurNRTIndex;
-import com.nearinfinity.blur.store.compressed.CompressedFieldDataDirectory;
-
-public class LocalIndexServer extends AbstractIndexServer {
-
-  private final static Log LOG = LogFactory.getLog(LocalIndexServer.class);
-
-  private Map<String, Map<String, BlurIndex>> _readersMap = new ConcurrentHashMap<String, Map<String, BlurIndex>>();
-  private File _localDir;
-  private BlurIndexCloser _closer;
-  private int _blockSize = 65536;
-  private CompressionCodec _compression = CompressedFieldDataDirectory.DEFAULT_COMPRESSION;
-  private Path _walPath;
-  private Configuration _configuration = new Configuration();
-
-  public LocalIndexServer(File file, Path walPath) {
-    _localDir = file;
-    _localDir.mkdirs();
-    _closer = new BlurIndexCloser();
-    _closer.init();
-    _walPath = walPath;
-  }
-
-  @Override
-  public BlurAnalyzer getAnalyzer(String table) {
-    return new BlurAnalyzer(new StandardAnalyzer(LUCENE_VERSION, new HashSet<String>()));
-  }
-
-  @Override
-  public SortedSet<String> getShardListCurrentServerOnly(String table) throws IOException {
-    Map<String, BlurIndex> tableMap = _readersMap.get(table);
-    Set<String> shardsSet;
-    if (tableMap == null) {
-      shardsSet = getIndexes(table).keySet();
-    } else {
-      shardsSet = tableMap.keySet();
-    }
-    return new TreeSet<String>(shardsSet);
-  }
-
-  @Override
-  public Map<String, BlurIndex> getIndexes(String table) throws IOException {
-    Map<String, BlurIndex> tableMap = _readersMap.get(table);
-    if (tableMap == null) {
-      tableMap = openFromDisk(table);
-      _readersMap.put(table, tableMap);
-    }
-    return tableMap;
-  }
-
-  @Override
-  public Similarity getSimilarity(String table) {
-    return new FairSimilarity();
-  }
-
-  @Override
-  public void close() {
-    _closer.close();
-    for (String table : _readersMap.keySet()) {
-      close(_readersMap.get(table));
-    }
-  }
-
-  private void close(Map<String, BlurIndex> map) {
-    for (BlurIndex index : map.values()) {
-      try {
-        index.close();
-      } catch (Exception e) {
-        LOG.error("Error while trying to close index.", e);
-      }
-    }
-  }
-
-  private Map<String, BlurIndex> openFromDisk(String table) throws IOException {
-    File tableFile = new File(_localDir, table);
-    if (tableFile.isDirectory()) {
-      Map<String, BlurIndex> shards = new ConcurrentHashMap<String, BlurIndex>();
-      for (File f : tableFile.listFiles()) {
-        if (f.isDirectory()) {
-          MMapDirectory directory = new MMapDirectory(f);
-          if (!IndexReader.indexExists(directory)) {
-            new IndexWriter(directory, new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer())).close();
-          }
-          String shardName = f.getName();
-          shards.put(shardName, openIndex(table, shardName, directory));
-        }
-      }
-      return shards;
-    }
-    throw new IOException("Table [" + table + "] not found.");
-  }
-
-  private BlurIndex openIndex(String table, String shard, Directory dir) throws CorruptIndexException, IOException {
-    BlurNRTIndex index = new BlurNRTIndex();
-    index.setAnalyzer(getAnalyzer(table));
-    index.setDirectory(dir);
-    index.setShard(shard);
-    index.setSimilarity(getSimilarity(table));
-    index.setTable(table);
-    index.setWalPath(new Path(new Path(_walPath, table), shard));
-    index.setConfiguration(_configuration);
-    index.setCloser(_closer);
-    index.setTimeBetweenRefreshs(25);
-    index.init();
-    return index;
-  }
-
-  @Override
-  public TABLE_STATUS getTableStatus(String table) {
-    return TABLE_STATUS.ENABLED;
-  }
-
-  @Override
-  public List<String> getShardList(String table) {
-    try {
-      List<String> result = new ArrayList<String>();
-      File tableFile = new File(_localDir, table);
-      if (tableFile.isDirectory()) {
-        for (File f : tableFile.listFiles()) {
-          if (f.isDirectory()) {
-            result.add(f.getName());
-          }
-        }
-      }
-      return result;
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-  @Override
-  public String getNodeName() {
-    return "localhost";
-  }
-
-  @Override
-  public String getTableUri(String table) {
-    return new File(_localDir, table).toURI().toString();
-  }
-
-  @Override
-  public int getShardCount(String table) {
-    return getShardList(table).size();
-  }
-
-  @Override
-  public int getCompressionBlockSize(String table) {
-    return _blockSize;
-  }
-
-  @Override
-  public CompressionCodec getCompressionCodec(String table) {
-    return _compression;
-  }
-
-  @Override
-  public long getTableSize(String table) throws IOException {
-    try {
-      File file = new File(new URI(getTableUri(table)));
-      return getFolderSize(file);
-    } catch (URISyntaxException e) {
-      throw new IOException("bad URI", e);
-    }
-  }
-
-  private long getFolderSize(File file) {
-    long size = 0;
-    if (file.isDirectory()) {
-      for (File sub : file.listFiles()) {
-        size += getFolderSize(sub);
-      }
-    } else {
-      size += file.length();
-    }
-    return size;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultComparator.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultComparator.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultComparator.java
deleted file mode 100644
index 80ec51a..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultComparator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.nearinfinity.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.
- */
-import java.util.Comparator;
-
-import com.nearinfinity.blur.thrift.generated.BlurResult;
-
-public class BlurResultComparator implements Comparator<BlurResult> {
-
-  @Override
-  public int compare(BlurResult o1, BlurResult o2) {
-    int compare = Double.compare(o2.score, o1.score);
-    if (compare == 0) {
-      return o2.locationId.compareTo(o1.locationId);
-    }
-    return compare;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterable.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterable.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterable.java
deleted file mode 100644
index 315fcee..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterable.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.nearinfinity.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.
- */
-import java.io.IOException;
-import java.util.Map;
-
-import com.nearinfinity.blur.thrift.generated.BlurResult;
-
-public interface BlurResultIterable extends Iterable<BlurResult> {
-
-  void skipTo(long skipTo);
-
-  long getTotalResults();
-
-  Map<String, Long> getShardInfo();
-
-  void close() throws IOException;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableClient.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableClient.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableClient.java
deleted file mode 100644
index 566aa7b..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableClient.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.nearinfinity.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.
- */
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicLongArray;
-
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.thrift.generated.Blur;
-import com.nearinfinity.blur.thrift.generated.BlurQuery;
-import com.nearinfinity.blur.thrift.generated.BlurResult;
-import com.nearinfinity.blur.thrift.generated.BlurResults;
-import com.nearinfinity.blur.thrift.generated.Blur.Client;
-
-public class BlurResultIterableClient implements BlurResultIterable {
-
-  private static final Log LOG = LogFactory.getLog(BlurResultIterableClient.class);
-
-  private Map<String, Long> _shardInfo = new TreeMap<String, Long>();
-  private Client _client;
-  private String _table;
-  private BlurResults _results;
-  private int _remoteFetchCount;
-  private int _batch = 0;
-  private long _totalResults;
-  private long _skipTo;
-  private AtomicLongArray _facetCounts;
-  private boolean _alreadyProcessed;
-  private BlurQuery _originalQuery;
-
-  public BlurResultIterableClient(Blur.Client client, String table, BlurQuery query, AtomicLongArray facetCounts, int remoteFetchCount) {
-    _client = client;
-    _table = table;
-    _facetCounts = facetCounts;
-    _originalQuery = query;
-    _remoteFetchCount = remoteFetchCount;
-    performSearch();
-  }
-
-  private void performSearch() {
-    try {
-      long cursor = _remoteFetchCount * _batch;
-      BlurQuery blurQuery = new BlurQuery(_originalQuery.simpleQuery, _originalQuery.expertQuery, _originalQuery.facets, null, false, _originalQuery.useCacheIfPresent, cursor,
-          _remoteFetchCount, _originalQuery.minimumNumberOfResults, _originalQuery.maxQueryTime, _originalQuery.uuid, _originalQuery.userContext, _originalQuery.cacheResult,
-          _originalQuery.startTime, _originalQuery.modifyFileCaches);
-      _results = _client.query(_table, blurQuery);
-      addFacets();
-      _totalResults = _results.totalResults;
-      _shardInfo.putAll(_results.shardInfo);
-      _batch++;
-    } catch (Exception e) {
-      LOG.error("Error during for [{0}]", e, _originalQuery);
-      throw new RuntimeException(e);
-    }
-  }
-
-  private void addFacets() {
-    if (!_alreadyProcessed) {
-      List<Long> counts = _results.facetCounts;
-      if (counts != null) {
-        int size = counts.size();
-        for (int i = 0; i < size; i++) {
-          _facetCounts.addAndGet(i, counts.get(i));
-        }
-      }
-      _alreadyProcessed = true;
-    }
-  }
-
-  @Override
-  public Map<String, Long> getShardInfo() {
-    return _shardInfo;
-  }
-
-  @Override
-  public long getTotalResults() {
-    return _totalResults;
-  }
-
-  @Override
-  public void skipTo(long skipTo) {
-    this._skipTo = skipTo;
-  }
-
-  @Override
-  public Iterator<BlurResult> iterator() {
-    SearchIterator iterator = new SearchIterator();
-    long start = 0;
-    while (iterator.hasNext() && start < _skipTo) {
-      iterator.next();
-      start++;
-    }
-    return iterator;
-  }
-
-  public class SearchIterator implements Iterator<BlurResult> {
-
-    private int position = 0;
-    private int relposition = 0;
-
-    @Override
-    public boolean hasNext() {
-      if (position < _originalQuery.minimumNumberOfResults && position < _totalResults) {
-        return true;
-      }
-      return false;
-    }
-
-    @Override
-    public BlurResult next() {
-      if (relposition >= _results.results.size()) {
-        performSearch();
-        relposition = 0;
-      }
-      position++;
-      return _results.results.get(relposition++);
-    }
-
-    @Override
-    public void remove() {
-
-    }
-  }
-
-  @Override
-  public void close() throws IOException {
-    // nothing
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableMultiple.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableMultiple.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableMultiple.java
deleted file mode 100644
index d204e46..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableMultiple.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.nearinfinity.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.
- */
-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 com.nearinfinity.blur.thrift.generated.BlurResult;
-import com.nearinfinity.blur.utils.BlurConstants;
-
-public class BlurResultIterableMultiple implements BlurResultIterable {
-
-  private long totalResults;
-  private Map<String, Long> shardInfo = new TreeMap<String, Long>();
-  private long skipTo;
-  private List<BlurResultIterable> results = new ArrayList<BlurResultIterable>();
-
-  public void addBlurResultIterable(BlurResultIterable iterable) {
-    totalResults += iterable.getTotalResults();
-    shardInfo.putAll(iterable.getShardInfo());
-    results.add(iterable);
-  }
-
-  @Override
-  public Map<String, Long> getShardInfo() {
-    return shardInfo;
-  }
-
-  @Override
-  public long getTotalResults() {
-    return totalResults;
-  }
-
-  @Override
-  public void skipTo(long skipTo) {
-    this.skipTo = skipTo;
-  }
-
-  @Override
-  public Iterator<BlurResult> iterator() {
-    MultipleHitsIterator iterator = new MultipleHitsIterator(results);
-    long start = 0;
-    while (iterator.hasNext() && start < skipTo) {
-      iterator.next();
-      start++;
-    }
-    return iterator;
-  }
-
-  public static class MultipleHitsIterator implements Iterator<BlurResult> {
-
-    private List<PeekableIterator<BlurResult>> iterators = new ArrayList<PeekableIterator<BlurResult>>();
-    private int length;
-
-    public MultipleHitsIterator(List<BlurResultIterable> hits) {
-      for (BlurResultIterable hitsIterable : hits) {
-        iterators.add(new PeekableIterator<BlurResult>(hitsIterable.iterator()));
-      }
-      length = iterators.size();
-    }
-
-    @Override
-    public boolean hasNext() {
-      for (int i = 0; i < length; i++) {
-        if (iterators.get(i).hasNext()) {
-          return true;
-        }
-      }
-      return false;
-    }
-
-    @Override
-    public BlurResult next() {
-      Collections.sort(iterators, BlurConstants.HITS_PEEKABLE_ITERATOR_COMPARATOR);
-      return fetchResult(iterators.get(0).next());
-    }
-
-    public BlurResult fetchResult(BlurResult next) {
-      return next;
-    }
-
-    @Override
-    public void remove() {
-
-    }
-  }
-
-  @Override
-  public void close() throws IOException {
-    for (BlurResultIterable it : results) {
-      it.close();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableSearcher.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableSearcher.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableSearcher.java
deleted file mode 100644
index 6b23fd8..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableSearcher.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package com.nearinfinity.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.
- */
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.ScoreDoc;
-
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.lucene.search.IterablePaging;
-import com.nearinfinity.blur.lucene.search.IterablePaging.ProgressRef;
-import com.nearinfinity.blur.lucene.search.IterablePaging.TotalHitsRef;
-import com.nearinfinity.blur.manager.IndexManager;
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.thrift.generated.BlurResult;
-import com.nearinfinity.blur.thrift.generated.FetchResult;
-import com.nearinfinity.blur.thrift.generated.Selector;
-import com.nearinfinity.blur.utils.Converter;
-import com.nearinfinity.blur.utils.IteratorConverter;
-
-public class BlurResultIterableSearcher implements BlurResultIterable {
-
-  private static final Log LOG = LogFactory.getLog(BlurResultIterableSearcher.class);
-
-  private Map<String, Long> _shardInfo = new TreeMap<String, Long>();
-  private String _shard;
-  private long _skipTo;
-  private String _table;
-  private int _fetchCount = 1000;
-
-  private IteratorConverter<ScoreDoc, BlurResult> _iterator;
-  private Selector _selector;
-  private Query _query;
-  private IndexSearcher _searcher;
-  private TotalHitsRef _totalHitsRef = new TotalHitsRef();
-  private ProgressRef _progressRef = new ProgressRef();
-  private AtomicBoolean _running;
-  private IndexReader _reader;
-
-  public BlurResultIterableSearcher(AtomicBoolean running, Query query, String table, String shard, IndexSearcher searcher, Selector selector, IndexReader reader)
-      throws IOException {
-    _running = running;
-    _table = table;
-    _query = query;
-    _shard = shard;
-    _searcher = searcher;
-    _selector = selector;
-    _reader = reader;
-    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));
-      }
-    });
-    _shardInfo.put(_shard, (long) _totalHitsRef.totalHits());
-  }
-
-  private FetchResult getFetchResult(String resolveId) throws IOException, BlurException {
-    if (_selector == null) {
-      return null;
-    }
-    FetchResult fetchResult = new FetchResult();
-    _selector.setLocationId(resolveId);
-    IndexManager.validSelector(_selector);
-    IndexManager.fetchRow(_searcher.getIndexReader(), _table, _selector, fetchResult);
-    return fetchResult;
-  }
-
-  @Override
-  public Map<String, Long> getShardInfo() {
-    return _shardInfo;
-  }
-
-  @Override
-  public long getTotalResults() {
-    return _totalHitsRef.totalHits();
-  }
-
-  @Override
-  public void skipTo(long skipTo) {
-    _skipTo = skipTo;
-  }
-
-  @Override
-  public Iterator<BlurResult> iterator() {
-    long start = 0;
-    while (_iterator.hasNext() && start < _skipTo) {
-      _iterator.next();
-      start++;
-    }
-    return _iterator;
-  }
-
-  private String resolveId(int docId) {
-    return _shard + "/" + docId;
-  }
-
-  @Override
-  public void close() throws IOException {
-    if (_reader != null) {
-      int refCount = _reader.getRefCount();
-      _reader.decRef();
-      LOG.debug("Decrementing reader old ref [{0}] new ref count [{1}]", refCount, _reader.getRefCount());
-      _reader = null;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableSimple.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableSimple.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableSimple.java
deleted file mode 100644
index f509b59..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultIterableSimple.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.nearinfinity.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.
- */
-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 com.nearinfinity.blur.thrift.generated.BlurResult;
-import com.nearinfinity.blur.utils.BlurConstants;
-
-public class BlurResultIterableSimple implements BlurResultIterable {
-
-  private List<BlurResult> results;
-  private Map<String, Long> shardInfo;
-  private long skipTo;
-
-  public BlurResultIterableSimple(String shard, List<BlurResult> hits) {
-    Collections.sort(hits, BlurConstants.HITS_COMPARATOR);
-    this.results = hits;
-    this.shardInfo = new TreeMap<String, Long>();
-    this.shardInfo.put(shard, (long) hits.size());
-  }
-
-  @Override
-  public Map<String, Long> getShardInfo() {
-    return shardInfo;
-  }
-
-  @Override
-  public long getTotalResults() {
-    return results.size();
-  }
-
-  @Override
-  public void skipTo(long skipTo) {
-    this.skipTo = skipTo;
-  }
-
-  @Override
-  public Iterator<BlurResult> iterator() {
-    long start = 0;
-    Iterator<BlurResult> iterator = results.iterator();
-    while (iterator.hasNext() && start < skipTo) {
-      iterator.next();
-      start++;
-    }
-    return iterator;
-  }
-
-  @Override
-  public void close() throws IOException {
-    // do nothing
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultPeekableIteratorComparator.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultPeekableIteratorComparator.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultPeekableIteratorComparator.java
deleted file mode 100644
index b6a5eaf..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/BlurResultPeekableIteratorComparator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.nearinfinity.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.
- */
-import java.util.Comparator;
-
-import com.nearinfinity.blur.thrift.generated.BlurResult;
-
-public class BlurResultPeekableIteratorComparator implements Comparator<PeekableIterator<BlurResult>> {
-
-  @Override
-  public int compare(PeekableIterator<BlurResult> o1, PeekableIterator<BlurResult> o2) {
-    BlurResult result1 = o1.peek();
-    BlurResult result2 = o2.peek();
-    if (result1 == null && result2 == null) {
-      return 0;
-    } else if (result1 == null) {
-      return 1;
-    } else if (result2 == null) {
-      return -1;
-    }
-    int compare = Double.compare(result2.score, result1.score);
-    if (compare == 0) {
-      return result2.locationId.compareTo(result1.locationId);
-    }
-    return compare;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/MergerBlurResultIterable.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/MergerBlurResultIterable.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/MergerBlurResultIterable.java
deleted file mode 100644
index 28dff36..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/MergerBlurResultIterable.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.nearinfinity.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.
- */
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.thrift.generated.BlurQuery;
-import com.nearinfinity.blur.utils.BlurExecutorCompletionService;
-import com.nearinfinity.blur.utils.ForkJoin.Merger;
-
-public class MergerBlurResultIterable implements Merger<BlurResultIterable> {
-
-  private static Log LOG = LogFactory.getLog(MergerBlurResultIterable.class);
-
-  private long _minimumNumberOfResults;
-  private long _maxQueryTime;
-  private BlurQuery _blurQuery;
-
-  public MergerBlurResultIterable(BlurQuery blurQuery) {
-    _blurQuery = blurQuery;
-    _minimumNumberOfResults = blurQuery.minimumNumberOfResults;
-    _maxQueryTime = blurQuery.maxQueryTime;
-  }
-
-  @Override
-  public BlurResultIterable merge(BlurExecutorCompletionService<BlurResultIterable> service) throws BlurException {
-    BlurResultIterableMultiple iterable = new BlurResultIterableMultiple();
-    while (service.getRemainingCount() > 0) {
-      Future<BlurResultIterable> future = service.poll(_maxQueryTime, TimeUnit.MILLISECONDS, true, _blurQuery);
-      if (future != null) {
-        BlurResultIterable blurResultIterable = service.getResultThrowException(future, _blurQuery);
-        iterable.addBlurResultIterable(blurResultIterable);
-        if (iterable.getTotalResults() >= _minimumNumberOfResults) {
-          service.cancelAll();// Called to stop execution of any other running
-                              // queries.
-          return iterable;
-        }
-      } 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);
-      }
-    }
-    return iterable;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/PeekableIterator.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/PeekableIterator.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/PeekableIterator.java
deleted file mode 100644
index 963cc34..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/results/PeekableIterator.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.nearinfinity.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.
- */
-import java.util.Iterator;
-
-public class PeekableIterator<E> implements Iterator<E> {
-
-  private Iterator<E> iterator;
-  private E current;
-
-  public PeekableIterator(Iterator<E> iterator) {
-    if (iterator.hasNext()) {
-      current = iterator.next();
-    }
-    this.iterator = iterator;
-  }
-
-  /**
-   * Only valid is hasNext is true. If hasNext if false, peek will return null;
-   * 
-   * @return <E>
-   */
-  public E peek() {
-    return current;
-  }
-
-  @Override
-  public boolean hasNext() {
-    if (current != null) {
-      return true;
-    }
-    return iterator.hasNext();
-  }
-
-  @Override
-  public E next() {
-    E next = null;
-    if (iterator.hasNext()) {
-      next = iterator.next();
-    }
-    E result = current;
-    current = next;
-    return result;
-  }
-
-  @Override
-  public void remove() {
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/LoadFactor.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/LoadFactor.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/LoadFactor.java
deleted file mode 100644
index 5a30033..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/LoadFactor.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package com.nearinfinity.blur.manager.stats;
-
-/**
- * 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.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-
-public class LoadFactor {
-
-  private static final Log LOG = LogFactory.getLog(LoadFactor.class);
-
-  public static void main(String[] args) throws InterruptedException {
-    LoadFactor loadFactor = new LoadFactor();
-    loadFactor.init();
-    loadFactor.add("heapUsed", new Sampler() {
-      private MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
-
-      @Override
-      public long sample() {
-        return bean.getHeapMemoryUsage().getUsed();
-      }
-    });
-
-    new Thread(new Runnable() {
-      @Override
-      public void run() {
-        long total = 0;
-        while (true) {
-          total += doWork();
-        }
-      }
-    }).start();
-
-    while (true) {
-      System.out.println("one     = " + (long) loadFactor.getOneMinuteLoadFactor("heapUsed"));
-      System.out.println("five    = " + (long) loadFactor.getFiveMinuteLoadFactor("heapUsed"));
-      System.out.println("fifteen = " + (long) loadFactor.getFifteenMinuteLoadFactor("heapUsed"));
-      Thread.sleep(5000);
-    }
-
-  }
-
-  protected static int doWork() {
-    StringBuilder builder = new StringBuilder();
-    int count = 0;
-    for (int i = 0; i < 10000000; i++) {
-      if (count == 1000) {
-        try {
-          Thread.sleep(1);
-        } catch (InterruptedException e) {
-          return 0;
-        }
-        count = 0;
-      }
-      builder.append('m');
-      count++;
-    }
-    return builder.toString().hashCode();
-  }
-
-  private Map<String, LoadFactorProcessor> _processors = new ConcurrentHashMap<String, LoadFactorProcessor>();
-  private Timer _timer;
-  private long _delay = TimeUnit.SECONDS.toMillis(1);
-  private long _period = TimeUnit.SECONDS.toMillis(1);
-
-  public void init() {
-    _timer = new Timer("LoadFactor-Daemon", true);
-    _timer.schedule(new TimerTask() {
-      @Override
-      public void run() {
-        try {
-          sampleAll();
-        } catch (Throwable e) {
-          LOG.error("Unknown error", e);
-        }
-      }
-    }, _delay, _period);
-
-  }
-
-  private void sampleAll() {
-    for (String name : _processors.keySet()) {
-      LoadFactorProcessor processor = _processors.get(name);
-      processor.sample();
-    }
-  }
-
-  public void add(String name, Sampler sampler) {
-    _processors.put(name, new LoadFactorProcessor(sampler));
-  }
-
-  public double getOneMinuteLoadFactor(String name) {
-    LoadFactorProcessor processor = _processors.get(name);
-    if (processor == null) {
-      return 0;
-    }
-    return processor.oneMinuteLoadFactor();
-  }
-
-  public double getFiveMinuteLoadFactor(String name) {
-    LoadFactorProcessor processor = _processors.get(name);
-    if (processor == null) {
-      return 0;
-    }
-    return processor.fiveMinuteLoadFactor();
-  }
-
-  public double getFifteenMinuteLoadFactor(String name) {
-    LoadFactorProcessor processor = _processors.get(name);
-    if (processor == null) {
-      return 0;
-    }
-    return processor.fifteenMinuteLoadFactor();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/LoadFactorProcessor.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/LoadFactorProcessor.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/LoadFactorProcessor.java
deleted file mode 100644
index ba02cd6..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/LoadFactorProcessor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.nearinfinity.blur.manager.stats;
-
-/**
- * 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.util.concurrent.TimeUnit;
-
-public class LoadFactorProcessor {
-
-  private final Sampler _sampler;
-  private final WeightedAvg _one;
-  private final WeightedAvg _five;
-  private final WeightedAvg _fifteen;
-
-  public LoadFactorProcessor(Sampler sampler) {
-    _sampler = sampler;
-    _one = new WeightedAvg((int) TimeUnit.MINUTES.toSeconds(1));
-    _five = new WeightedAvg((int) TimeUnit.MINUTES.toSeconds(5));
-    _fifteen = new WeightedAvg((int) TimeUnit.MINUTES.toSeconds(15));
-  }
-
-  public void sample() {
-    long sample = _sampler.sample();
-    _one.add(sample);
-    _five.add(sample);
-    _fifteen.add(sample);
-  }
-
-  public double oneMinuteLoadFactor() {
-    return _one.getAvg();
-  }
-
-  public double fiveMinuteLoadFactor() {
-    return _five.getAvg();
-  }
-
-  public double fifteenMinuteLoadFactor() {
-    return _fifteen.getAvg();
-  }
-
-  public Sampler getSampler() {
-    return _sampler;
-  }
-
-  public WeightedAvg getOne() {
-    return _one;
-  }
-
-  public WeightedAvg getFive() {
-    return _five;
-  }
-
-  public WeightedAvg getFifteen() {
-    return _fifteen;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/MergerTableStats.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/MergerTableStats.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/MergerTableStats.java
deleted file mode 100644
index 6afd3a2..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/MergerTableStats.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.nearinfinity.blur.manager.stats;
-
-/**
- * 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.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.thrift.generated.TableStats;
-import com.nearinfinity.blur.utils.BlurExecutorCompletionService;
-import com.nearinfinity.blur.utils.ForkJoin.Merger;
-
-public class MergerTableStats implements Merger<TableStats> {
-
-  private long _timeout;
-
-  public MergerTableStats(long timeout) {
-    _timeout = timeout;
-  }
-
-  @Override
-  public TableStats merge(BlurExecutorCompletionService<TableStats> service) throws BlurException {
-    TableStats result = new TableStats();
-    while (service.getRemainingCount() > 0) {
-      Future<TableStats> tableStats = service.poll(_timeout, TimeUnit.MILLISECONDS, true);
-      TableStats stats = service.getResultThrowException(tableStats);
-      result = merge(result, stats);
-    }
-    return result;
-  }
-
-  private TableStats merge(TableStats s1, TableStats s2) {
-    s1.tableName = s2.tableName;
-    s1.bytes = Math.max(s1.bytes, s2.bytes);
-    s1.recordCount = s1.recordCount + s2.recordCount;
-    s1.rowCount = s1.rowCount + s2.rowCount;
-    s1.queries = Math.max(s1.queries, s2.queries);
-    return s1;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/Sampler.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/Sampler.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/Sampler.java
deleted file mode 100644
index 3d01589..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/Sampler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.nearinfinity.blur.manager.stats;
-
-/**
- * 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 Sampler {
-
-  long sample();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/WeightedAvg.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/WeightedAvg.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/WeightedAvg.java
deleted file mode 100644
index e1bb680..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/stats/WeightedAvg.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.nearinfinity.blur.manager.stats;
-
-/**
- * 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 class WeightedAvg {
-
-  private final int _maxSize;
-  private final long[] _values;
-  private int _numberOfAdds;
-  private int _currentPosition;
-  private long _totalValue = 0;
-
-  public WeightedAvg(int maxSize) {
-    _maxSize = maxSize;
-    _values = new long[_maxSize];
-    _numberOfAdds = 0;
-    _currentPosition = 0;
-  }
-
-  public void add(long value) {
-    if (_currentPosition >= _maxSize) {
-      _currentPosition = 0;
-    }
-    long currentValue = _values[_currentPosition];
-    _values[_currentPosition] = value;
-    _totalValue += value - currentValue;
-    _numberOfAdds++;
-    _currentPosition++;
-  }
-
-  public double getAvg() {
-    if (_totalValue == 0) {
-      return 0;
-    }
-    return (double) _totalValue / (double) Math.min(_numberOfAdds, _maxSize);
-  }
-
-  public int getMaxSize() {
-    return _maxSize;
-  }
-
-  public long[] getValues() {
-    return _values;
-  }
-
-  public int getNumberOfAdds() {
-    return _numberOfAdds;
-  }
-
-  public int getCurrentPosition() {
-    return _currentPosition;
-  }
-
-  public long getTotalValue() {
-    return _totalValue;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/MergerQueryStatus.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/MergerQueryStatus.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/MergerQueryStatus.java
deleted file mode 100644
index c4cebab..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/MergerQueryStatus.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.nearinfinity.blur.manager.status;
-
-/**
- * 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.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.thrift.generated.BlurQueryStatus;
-import com.nearinfinity.blur.thrift.generated.CpuTime;
-import com.nearinfinity.blur.thrift.generated.QueryState;
-import com.nearinfinity.blur.utils.BlurExecutorCompletionService;
-import com.nearinfinity.blur.utils.ForkJoin.Merger;
-
-public class MergerQueryStatus implements Merger<List<BlurQueryStatus>> {
-
-  private long _timeout;
-
-  public MergerQueryStatus(long timeout) {
-    _timeout = timeout;
-  }
-
-  @Override
-  public List<BlurQueryStatus> merge(BlurExecutorCompletionService<List<BlurQueryStatus>> service) throws BlurException {
-    Map<Long, BlurQueryStatus> statusMap = new HashMap<Long, BlurQueryStatus>();
-    while (service.getRemainingCount() > 0) {
-      Future<List<BlurQueryStatus>> future = service.poll(_timeout, TimeUnit.MILLISECONDS, true);
-      List<BlurQueryStatus> status = service.getResultThrowException(future);
-      addToMap(statusMap, status);
-    }
-    return new ArrayList<BlurQueryStatus>(statusMap.values());
-  }
-
-  private void addToMap(Map<Long, BlurQueryStatus> statusMap, List<BlurQueryStatus> list) {
-    for (BlurQueryStatus status : list) {
-      BlurQueryStatus searchQueryStatus = statusMap.get(status.uuid);
-      if (searchQueryStatus == null) {
-        statusMap.put(status.uuid, status);
-      } else {
-        statusMap.put(status.uuid, merge(searchQueryStatus, status));
-      }
-    }
-  }
-
-  public static BlurQueryStatus merge(BlurQueryStatus s1, BlurQueryStatus s2) {
-    s1.completeShards = s1.completeShards + s2.completeShards;
-    s1.totalShards = s1.totalShards + s2.totalShards;
-    if (s1.state != s2.state) {
-      if (s1.state == QueryState.INTERRUPTED || s2.state == QueryState.INTERRUPTED) {
-        s1.state = QueryState.INTERRUPTED;
-      } else if (s1.state == QueryState.RUNNING || s2.state == QueryState.RUNNING) {
-        s1.state = QueryState.RUNNING;
-      } else {
-        s1.state = QueryState.COMPLETE;
-      }
-    }
-    if (s1.cpuTimes == null) {
-      s1.cpuTimes = new HashMap<String, CpuTime>();
-    }
-    if (s2.cpuTimes != null) {
-      s1.cpuTimes.putAll(s2.cpuTimes);
-    }
-    return s1;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/MergerQueryStatusSingle.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/MergerQueryStatusSingle.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/MergerQueryStatusSingle.java
deleted file mode 100644
index 2455f3e..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/MergerQueryStatusSingle.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.nearinfinity.blur.manager.status;
-
-/**
- * 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.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.thrift.generated.BlurQueryStatus;
-import com.nearinfinity.blur.utils.BlurExecutorCompletionService;
-import com.nearinfinity.blur.utils.ForkJoin.Merger;
-
-public class MergerQueryStatusSingle implements Merger<BlurQueryStatus> {
-
-  private long _timeout;
-
-  public MergerQueryStatusSingle(long timeout) {
-    _timeout = timeout;
-  }
-
-  @Override
-  public BlurQueryStatus merge(BlurExecutorCompletionService<BlurQueryStatus> service) throws BlurException {
-    BlurQueryStatus result = null;
-    while (service.getRemainingCount() > 0) {
-      Future<BlurQueryStatus> future = service.poll(_timeout, TimeUnit.MILLISECONDS, true);
-      BlurQueryStatus status = service.getResultThrowException(future);
-      if (result == null) {
-        result = status;
-      } else {
-        result = MergerQueryStatus.merge(result, status);
-      }
-    }
-    return result;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/QueryStatus.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/QueryStatus.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/QueryStatus.java
deleted file mode 100644
index 7fca0a3..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/QueryStatus.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package com.nearinfinity.blur.manager.status;
-
-/**
- * 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.lang.management.ManagementFactory;
-import java.lang.management.ThreadMXBean;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-import com.nearinfinity.blur.thrift.generated.BlurQuery;
-import com.nearinfinity.blur.thrift.generated.BlurQueryStatus;
-import com.nearinfinity.blur.thrift.generated.QueryState;
-
-public class QueryStatus implements Comparable<QueryStatus> {
-
-  private final static boolean CPU_TIME_SUPPORTED = ManagementFactory.getThreadMXBean().isCurrentThreadCpuTimeSupported();
-
-  private final BlurQuery _blurQuery;
-  private final String _table;
-  private final long _startingTime;
-  private boolean _finished = false;
-  private long _finishedTime;
-  private final AtomicLong _cpuTimeOfFinishedThreads = new AtomicLong();
-  private final ThreadMXBean _bean = ManagementFactory.getThreadMXBean();
-  private final long _ttl;
-  private final ThreadLocal<Long> _cpuTimes = new ThreadLocal<Long>();
-  private final AtomicBoolean _interrupted = new AtomicBoolean(false);
-  private final AtomicInteger _totalShards = new AtomicInteger();
-  private final AtomicInteger _completeShards = new AtomicInteger();
-  private AtomicBoolean _running;
-
-  public QueryStatus(long ttl, String table, BlurQuery blurQuery, AtomicBoolean running) {
-    _ttl = ttl;
-    _table = table;
-    _blurQuery = blurQuery;
-    _startingTime = System.currentTimeMillis();
-    _running = running;
-  }
-
-  public QueryStatus attachThread() {
-    if (CPU_TIME_SUPPORTED) {
-      _cpuTimes.set(_bean.getCurrentThreadCpuTime());
-    } else {
-      _cpuTimes.set(-1L);
-    }
-    _totalShards.incrementAndGet();
-    return this;
-  }
-
-  public QueryStatus deattachThread() {
-    _completeShards.incrementAndGet();
-    if (CPU_TIME_SUPPORTED) {
-      long startingThreadCpuTime = _cpuTimes.get();
-      long currentThreadCpuTime = _bean.getCurrentThreadCpuTime();
-      _cpuTimeOfFinishedThreads.addAndGet(currentThreadCpuTime - startingThreadCpuTime);
-    }
-    return this;
-  }
-
-  public long getUserUuid() {
-    return _blurQuery.uuid;
-  }
-
-  public void cancelQuery() {
-    _interrupted.set(true);
-    _running.set(false);
-  }
-
-  public BlurQueryStatus getQueryStatus() {
-    BlurQueryStatus queryStatus = new BlurQueryStatus();
-    queryStatus.query = _blurQuery;
-    queryStatus.totalShards = _totalShards.get();
-    queryStatus.completeShards = _completeShards.get();
-    queryStatus.state = getQueryState();
-    if (queryStatus.query != null) {
-      queryStatus.uuid = queryStatus.query.uuid;
-    }
-    return queryStatus;
-  }
-
-  private QueryState getQueryState() {
-    if (_interrupted.get()) {
-      return QueryState.INTERRUPTED;
-    } else if (_finished) {
-      return QueryState.COMPLETE;
-    } else {
-      return QueryState.RUNNING;
-    }
-  }
-
-  public String getTable() {
-    return _table;
-  }
-
-  public boolean isFinished() {
-    return _finished;
-  }
-
-  public void setFinished(boolean finished) {
-    this._finished = finished;
-    _finishedTime = System.currentTimeMillis();
-  }
-
-  public long getFinishedTime() {
-    return _finishedTime;
-  }
-
-  public boolean isValidForCleanUp() {
-    if (!isFinished()) {
-      return false;
-    }
-    if (getFinishedTime() + _ttl < System.currentTimeMillis()) {
-      return true;
-    }
-    return false;
-  }
-
-  @Override
-  public int compareTo(QueryStatus o) {
-    long startingTime2 = o._startingTime;
-    if (_startingTime == startingTime2) {
-      int hashCode2 = o.hashCode();
-      return hashCode() < hashCode2 ? -1 : 1;
-    }
-    return _startingTime < startingTime2 ? -1 : 1;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/QueryStatusManager.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/QueryStatusManager.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/QueryStatusManager.java
deleted file mode 100644
index 5d7918b..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/status/QueryStatusManager.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.nearinfinity.blur.manager.status;
-
-/**
- * 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.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.thrift.generated.BlurQuery;
-import com.nearinfinity.blur.thrift.generated.BlurQueryStatus;
-
-public class QueryStatusManager {
-
-  private static final Log LOG = LogFactory.getLog(QueryStatusManager.class);
-  private static final Object CONSTANT_VALUE = new Object();
-
-  private Timer statusCleanupTimer;
-  private long statusCleanupTimerDelay = TimeUnit.SECONDS.toMillis(10);
-  private ConcurrentHashMap<QueryStatus, Object> currentQueryStatusCollection = new ConcurrentHashMap<QueryStatus, Object>();
-
-  public void init() {
-    statusCleanupTimer = new Timer("Query-Status-Cleanup", true);
-    statusCleanupTimer.schedule(new TimerTask() {
-      @Override
-      public void run() {
-        try {
-          cleanupFinishedQueryStatuses();
-        } catch (Throwable e) {
-          LOG.error("Unknown error while trying to cleanup finished queries.", e);
-        }
-      }
-    }, statusCleanupTimerDelay, statusCleanupTimerDelay);
-  }
-
-  public void close() {
-    statusCleanupTimer.cancel();
-    statusCleanupTimer.purge();
-  }
-
-  public QueryStatus newQueryStatus(String table, BlurQuery blurQuery, int maxNumberOfThreads, AtomicBoolean running) {
-    QueryStatus queryStatus = new QueryStatus(statusCleanupTimerDelay, table, blurQuery, running);
-    currentQueryStatusCollection.put(queryStatus, CONSTANT_VALUE);
-    return queryStatus;
-  }
-
-  public void removeStatus(QueryStatus status) {
-    status.setFinished(true);
-  }
-
-  private void cleanupFinishedQueryStatuses() {
-    LOG.debug("QueryStatus Start count [{0}].", currentQueryStatusCollection.size());
-    Iterator<QueryStatus> iterator = currentQueryStatusCollection.keySet().iterator();
-    while (iterator.hasNext()) {
-      QueryStatus status = iterator.next();
-      if (status.isValidForCleanUp()) {
-        currentQueryStatusCollection.remove(status);
-      }
-    }
-    LOG.debug("QueryStatus Finish count [{0}].", currentQueryStatusCollection.size());
-  }
-
-  public long getStatusCleanupTimerDelay() {
-    return statusCleanupTimerDelay;
-  }
-
-  public void setStatusCleanupTimerDelay(long statusCleanupTimerDelay) {
-    this.statusCleanupTimerDelay = statusCleanupTimerDelay;
-  }
-
-  public void cancelQuery(String table, long uuid) {
-    for (QueryStatus status : currentQueryStatusCollection.keySet()) {
-      if (status.getUserUuid() == uuid && status.getTable().equals(table)) {
-        status.cancelQuery();
-      }
-    }
-  }
-
-  public List<BlurQueryStatus> currentQueries(String table) {
-    List<BlurQueryStatus> result = new ArrayList<BlurQueryStatus>();
-    for (QueryStatus status : currentQueryStatusCollection.keySet()) {
-      if (status.getTable().equals(table)) {
-        result.add(status.getQueryStatus());
-      }
-    }
-    return result;
-  }
-
-  public BlurQueryStatus queryStatus(String table, long uuid) throws BlurException {
-    for (QueryStatus status : currentQueryStatusCollection.keySet()) {
-      if (status.getUserUuid() == uuid && status.getTable().equals(table)) {
-        return status.getQueryStatus();
-      }
-    }
-    throw new BlurException("Query status for table [" + table + "] and uuid [" + uuid + "] not found", null);
-  }
-
-  public List<Long> queryStatusIdList(String table) {
-    Set<Long> ids = new HashSet<Long>();
-    for (QueryStatus status : currentQueryStatusCollection.keySet()) {
-      ids.add(status.getUserUuid());
-    }
-    return new ArrayList<Long>(ids);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/AbstractBlurIndex.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/AbstractBlurIndex.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/AbstractBlurIndex.java
deleted file mode 100644
index c6f46e5..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/AbstractBlurIndex.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package com.nearinfinity.blur.manager.writer;
-
-/**
- * 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 static com.nearinfinity.blur.lucene.LuceneConstant.LUCENE_VERSION;
-
-import java.io.IOException;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.lucene.index.IndexDeletionPolicy;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy;
-import org.apache.lucene.index.TieredMergePolicy;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.store.Directory;
-
-import com.nearinfinity.blur.analysis.BlurAnalyzer;
-
-public abstract class AbstractBlurIndex extends BlurIndex {
-
-  private BlurAnalyzer _analyzer;
-  private BlurIndexCloser _closer;
-  private Directory _directory;
-  private IndexDeletionPolicy _indexDeletionPolicy = new KeepOnlyLastCommitDeletionPolicy();
-  private AtomicReference<IndexReader> _indexReaderRef = new AtomicReference<IndexReader>();
-  private AtomicBoolean _isClosed = new AtomicBoolean(false);
-  private AtomicBoolean _open = new AtomicBoolean();
-  private BlurIndexRefresher _refresher;
-  private String _shard;
-  private Similarity _similarity;
-  private String _table;
-
-  protected IndexWriterConfig initIndexWriterConfig() {
-    IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, _analyzer);
-    conf.setWriteLockTimeout(TimeUnit.MINUTES.toMillis(5));
-    conf.setIndexDeletionPolicy(_indexDeletionPolicy);
-    conf.setSimilarity(_similarity);
-    TieredMergePolicy mergePolicy = (TieredMergePolicy) conf.getMergePolicy();
-    mergePolicy.setUseCompoundFile(false);
-    _open.set(true);
-    return conf;
-  }
-
-  protected void initIndexReader(IndexReader reader) throws IOException {
-    _indexReaderRef.set(reader);
-    _refresher.register(this);
-  }
-
-  @Override
-  public void refresh() throws IOException {
-    if (!_open.get()) {
-      return;
-    }
-    IndexReader oldReader = _indexReaderRef.get();
-    if (oldReader.isCurrent()) {
-      return;
-    }
-    IndexReader reader = IndexReader.openIfChanged(oldReader);
-    if (reader != null && oldReader != reader) {
-      _indexReaderRef.set(reader);
-      _closer.close(oldReader);
-    }
-  }
-
-  @Override
-  public IndexReader getIndexReader() throws IOException {
-    IndexReader indexReader = _indexReaderRef.get();
-    indexReader.incRef();
-    return indexReader;
-  }
-
-  @Override
-  public void close() throws IOException {
-    close(null);
-    _directory.close();
-  }
-
-  public void close(Callable<Void> innerClose) throws IOException {
-    _open.set(false);
-    _refresher.unregister(this);
-    if (innerClose != null) {
-      try {
-        innerClose.call();
-      } catch (Exception e) {
-        throw new IOException(e);
-      }
-    }
-    _isClosed.set(true);
-  }
-
-  @Override
-  public AtomicBoolean isClosed() {
-    return _isClosed;
-  }
-
-  public void setAnalyzer(BlurAnalyzer analyzer) {
-    _analyzer = analyzer;
-  }
-
-  public void setCloser(BlurIndexCloser closer) {
-    _closer = closer;
-  }
-
-  public void setDirectory(Directory directory) {
-    _directory = directory;
-  }
-
-  public void setIndexDeletionPolicy(IndexDeletionPolicy indexDeletionPolicy) {
-    _indexDeletionPolicy = indexDeletionPolicy;
-  }
-
-  public void setRefresher(BlurIndexRefresher refresher) {
-    _refresher = refresher;
-  }
-
-  public void setShard(String shard) {
-    this._shard = shard;
-  }
-
-  public void setSimilarity(Similarity similarity) {
-    _similarity = similarity;
-  }
-
-  public void setTable(String table) {
-    this._table = table;
-  }
-
-  protected BlurAnalyzer getAnalyzer() {
-    return _analyzer;
-  }
-
-  protected Directory getDirectory() {
-    return _directory;
-  }
-
-  protected String getShard() {
-    return _shard;
-  }
-
-  protected String getTable() {
-    return _table;
-  }
-
-  protected boolean isOpen() {
-    return _open.get();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/BlurIndex.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/BlurIndex.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/BlurIndex.java
deleted file mode 100644
index ff388d9..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/BlurIndex.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.nearinfinity.blur.manager.writer;
-
-/**
- * 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.atomic.AtomicBoolean;
-
-import org.apache.lucene.index.IndexReader;
-
-import com.nearinfinity.blur.thrift.generated.Row;
-
-public abstract class BlurIndex {
-
-  public abstract void replaceRow(boolean waitToBeVisible, boolean wal, Row row) throws IOException;
-
-  public abstract void deleteRow(boolean waitToBeVisible, boolean wal, String rowId) throws IOException;
-
-  public abstract IndexReader getIndexReader() throws IOException;
-
-  public abstract void close() throws IOException;
-
-  public abstract void refresh() throws IOException;
-
-  public abstract AtomicBoolean isClosed();
-
-  public abstract void optimize(int numberOfSegmentsPerShard) throws IOException;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/BlurIndexCloser.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/BlurIndexCloser.java b/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/BlurIndexCloser.java
deleted file mode 100644
index 4aee08d..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/manager/writer/BlurIndexCloser.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.nearinfinity.blur.manager.writer;
-
-/**
- * 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.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.lucene.index.IndexReader;
-
-import com.nearinfinity.blur.concurrent.Executors;
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-
-public class BlurIndexCloser implements Runnable {
-
-  private static final Log LOG = LogFactory.getLog(BlurIndexCloser.class);
-  private static final long PAUSE_TIME = TimeUnit.SECONDS.toMillis(1);
-  private Thread daemon;
-  private Collection<IndexReader> readers = new LinkedBlockingQueue<IndexReader>();
-  private AtomicBoolean running = new AtomicBoolean();
-  private ExecutorService executorService;
-
-  public void init() {
-    running.set(true);
-    daemon = new Thread(this);
-    daemon.setDaemon(true);
-    daemon.setName(getClass().getName() + "-Daemon");
-    daemon.start();
-    LOG.info("Init Complete");
-    executorService = Executors.newThreadPool("Blur Index Closer Pool", 10);
-  }
-
-  public void close() {
-    running.set(false);
-    daemon.interrupt();
-    executorService.shutdownNow();
-  }
-
-  public void close(IndexReader reader) {
-    readers.add(reader);
-  }
-
-  @Override
-  public void run() {
-    while (running.get()) {
-      try {
-        tryToCloseReaders();
-      } catch (Throwable t) {
-        LOG.error("Unknown error", t);
-      }
-      try {
-        Thread.sleep(PAUSE_TIME);
-      } catch (InterruptedException e) {
-        return;
-      }
-    }
-  }
-
-  private void tryToCloseReaders() {
-    LOG.debug("Trying to close [{0}] readers", readers.size());
-    Iterator<IndexReader> it = readers.iterator();
-    while (it.hasNext()) {
-      IndexReader reader = it.next();
-      if (reader.getRefCount() == 1) {
-        it.remove();
-        closeInternal(reader);
-      } else {
-        LOG.debug("Could not close indexreader [" + reader + "] because of ref count [" + reader.getRefCount() + "].");
-      }
-      closeInternal(reader);
-    }
-  }
-
-  private void closeInternal(final IndexReader reader) {
-    executorService.submit(new Runnable() {
-      @Override
-      public void run() {
-        try {
-          long s = System.currentTimeMillis();
-          reader.close();
-          long e = System.currentTimeMillis();
-          LOG.debug("Size [{0}] time to close [{1}] Closing indexreader [{2}].", readers.size(), (e - s), reader);
-        } catch (Exception e) {
-          readers.add(reader);
-          LOG.error("Error while trying to close indexreader [" + reader + "].", e);
-        }
-      }
-    });
-  }
-}
\ No newline at end of file


Mime
View raw message