incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [6/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/thrift/BlurShardServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/BlurShardServer.java b/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/BlurShardServer.java
deleted file mode 100644
index 9225b24..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/BlurShardServer.java
+++ /dev/null
@@ -1,322 +0,0 @@
-package com.nearinfinity.blur.thrift;
-
-/**
- * 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.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLongArray;
-
-import org.apache.thrift.TException;
-
-import com.nearinfinity.blur.concurrent.Executors;
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.manager.BlurQueryChecker;
-import com.nearinfinity.blur.manager.IndexManager;
-import com.nearinfinity.blur.manager.IndexServer;
-import com.nearinfinity.blur.manager.results.BlurResultIterable;
-import com.nearinfinity.blur.manager.writer.BlurIndex;
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.thrift.generated.BlurQuery;
-import com.nearinfinity.blur.thrift.generated.BlurQueryStatus;
-import com.nearinfinity.blur.thrift.generated.BlurResults;
-import com.nearinfinity.blur.thrift.generated.FetchResult;
-import com.nearinfinity.blur.thrift.generated.RowMutation;
-import com.nearinfinity.blur.thrift.generated.Schema;
-import com.nearinfinity.blur.thrift.generated.Selector;
-import com.nearinfinity.blur.thrift.generated.TableStats;
-import com.nearinfinity.blur.thrift.generated.Blur.Iface;
-import com.nearinfinity.blur.utils.BlurConstants;
-import com.nearinfinity.blur.utils.BlurUtil;
-import com.nearinfinity.blur.utils.QueryCache;
-import com.nearinfinity.blur.utils.QueryCacheEntry;
-import com.nearinfinity.blur.utils.QueryCacheKey;
-
-public class BlurShardServer extends TableAdmin implements Iface {
-
-  private static final Log LOG = LogFactory.getLog(BlurShardServer.class);
-  private IndexManager _indexManager;
-  private IndexServer _indexServer;
-  private boolean _closed;
-  private long _maxTimeToLive = TimeUnit.MINUTES.toMillis(1);
-  private int _maxQueryCacheElements = 128;
-  private QueryCache _queryCache;
-  private BlurQueryChecker _queryChecker;
-  private ExecutorService _dataFetch;
-  private String _cluster = BlurConstants.BLUR_CLUSTER;
-  private int _dataFetchThreadCount = 32;
-
-  public void init() {
-    _queryCache = new QueryCache("shard-cache", _maxQueryCacheElements, _maxTimeToLive);
-    _dataFetch = Executors.newThreadPool("data-fetch-", _dataFetchThreadCount);
-  }
-
-  @Override
-  public BlurResults query(String table, BlurQuery blurQuery) throws BlurException, TException {
-    checkTable(_cluster, table);
-    _queryChecker.checkQuery(blurQuery);
-    try {
-      BlurQuery original = new BlurQuery(blurQuery);
-      if (blurQuery.useCacheIfPresent) {
-        LOG.debug("Using cache for query [{0}] on table [{1}].", blurQuery, table);
-        QueryCacheKey key = QueryCache.getNormalizedBlurQueryKey(table, blurQuery);
-        QueryCacheEntry queryCacheEntry = _queryCache.get(key);
-        if (_queryCache.isValid(queryCacheEntry, _indexServer.getShardListCurrentServerOnly(table))) {
-          LOG.debug("Cache hit for query [{0}] on table [{1}].", blurQuery, table);
-          return queryCacheEntry.getBlurResults(blurQuery);
-        } else {
-          _queryCache.remove(key);
-        }
-      }
-      BlurUtil.setStartTime(original);
-      BlurResultIterable hitsIterable = null;
-      try {
-        AtomicLongArray facetCounts = BlurUtil.getAtomicLongArraySameLengthAsList(blurQuery.facets);
-        hitsIterable = _indexManager.query(table, blurQuery, facetCounts);
-        return _queryCache.cache(table, original, BlurUtil.convertToHits(hitsIterable, blurQuery, facetCounts, _dataFetch, blurQuery.selector, this, table));
-      } catch (Exception e) {
-        LOG.error("Unknown error during search of [table={0},searchQuery={1}]", e, table, blurQuery);
-        throw new BException(e.getMessage(), e);
-      } finally {
-        if (hitsIterable != null) {
-          hitsIterable.close();
-        }
-      }
-    } catch (IOException e) {
-      LOG.error("Unknown error during search of [table={0},searchQuery={1}]", e, table, blurQuery);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public FetchResult fetchRow(String table, Selector selector) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      FetchResult fetchResult = new FetchResult();
-      _indexManager.fetchRow(table, selector, fetchResult);
-      return fetchResult;
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get fetch row [table={0},selector={1}]", e, table, selector);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public void cancelQuery(String table, long uuid) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      _indexManager.cancelQuery(table, uuid);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to cancel search [uuid={0}]", e, uuid);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public List<BlurQueryStatus> currentQueries(String table) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      return _indexManager.currentQueries(table);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get current search status [table={0}]", e, table);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public TableStats tableStats(String table) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      TableStats tableStats = new TableStats();
-      tableStats.tableName = table;
-      tableStats.recordCount = _indexServer.getRecordCount(table);
-      tableStats.rowCount = _indexServer.getRowCount(table);
-      tableStats.bytes = _indexServer.getTableSize(table);
-      tableStats.queries = 0;
-      return tableStats;
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get table stats [table={0}]", e, table);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  public synchronized void close() {
-    if (!_closed) {
-      _closed = true;
-      _indexManager.close();
-      _dataFetch.shutdownNow();
-    }
-  }
-
-  @Override
-  public Map<String, String> shardServerLayout(String table) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      Map<String, BlurIndex> blurIndexes = _indexServer.getIndexes(table);
-      Map<String, String> result = new TreeMap<String, String>();
-      String nodeName = _indexServer.getNodeName();
-      for (String shard : blurIndexes.keySet()) {
-        result.put(shard, nodeName);
-      }
-      return result;
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to getting shardServerLayout for table [" + table + "]", e);
-      if (e instanceof BlurException) {
-        throw (BlurException) e;
-      }
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public long recordFrequency(String table, String columnFamily, String columnName, String value) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      return _indexManager.recordFrequency(table, columnFamily, columnName, value);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get record frequency for [table={0},columnFamily={1},columnName={2},value={3}]", e, table, columnFamily, columnName, value);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public Schema schema(String table) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      return _indexManager.schema(table);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get schema for table [{0}={1}]", e, "table", table);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public List<String> terms(String table, String columnFamily, String columnName, String startWith, short size) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      return _indexManager.terms(table, columnFamily, columnName, startWith, size);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get terms list for [table={0},columnFamily={1},columnName={2},startWith={3},size={4}]", e, table, columnFamily, columnName,
-          startWith, size);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public void mutate(RowMutation mutation) throws BlurException, TException {
-    checkTable(_cluster, mutation.table);
-    checkForUpdates(_cluster, mutation.table);
-    MutationHelper.validateMutation(mutation);
-    try {
-      _indexManager.mutate(mutation);
-    } catch (Exception e) {
-      LOG.error("Unknown error during processing of [mutation={0}]", e, mutation);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public void mutateBatch(List<RowMutation> mutations) throws BlurException, TException {
-    long s = System.nanoTime();
-    for (RowMutation mutation : mutations) {
-      checkTable(_cluster, mutation.table);
-      checkForUpdates(_cluster, mutation.table);
-      MutationHelper.validateMutation(mutation);
-    }
-    try {
-      _indexManager.mutate(mutations);
-    } catch (Exception e) {
-      LOG.error("Unknown error during processing of [mutations={0}]", e, mutations);
-      throw new BException(e.getMessage(), e);
-    }
-    long e = System.nanoTime();
-    LOG.debug("mutateBatch took [" + (e - s) / 1000000.0 + " ms] to complete");
-  }
-
-  public long getMaxTimeToLive() {
-    return _maxTimeToLive;
-  }
-
-  public void setMaxTimeToLive(long maxTimeToLive) {
-    _maxTimeToLive = maxTimeToLive;
-  }
-
-  public int getMaxQueryCacheElements() {
-    return _maxQueryCacheElements;
-  }
-
-  public void setMaxQueryCacheElements(int maxQueryCacheElements) {
-    _maxQueryCacheElements = maxQueryCacheElements;
-  }
-
-  public void setQueryChecker(BlurQueryChecker queryChecker) {
-    _queryChecker = queryChecker;
-  }
-
-  public void setIndexManager(IndexManager indexManager) {
-    _indexManager = indexManager;
-  }
-
-  public void setIndexServer(IndexServer indexServer) {
-    _indexServer = indexServer;
-  }
-
-  @Override
-  public BlurQueryStatus queryStatusById(String table, long uuid) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      return _indexManager.queryStatus(table, uuid);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get current query status [table={0},uuid={1}]", e, table, uuid);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public List<Long> queryStatusIdList(String table) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      return _indexManager.queryStatusIdList(table);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get query status id list [table={0}]", e, table);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public void optimize(String table, int numberOfSegmentsPerShard) throws BlurException, TException {
-    checkTable(_cluster, table);
-    try {
-      _indexManager.optimize(table, numberOfSegmentsPerShard);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to optimize [table={0},numberOfSegmentsPerShard={1}]", e, table, numberOfSegmentsPerShard);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  public int getDataFetchThreadCount() {
-    return _dataFetchThreadCount;
-  }
-
-  public void setDataFetchThreadCount(int dataFetchThreadCount) {
-    _dataFetchThreadCount = dataFetchThreadCount;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ExecutorServicePerMethodCallThriftServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ExecutorServicePerMethodCallThriftServer.java b/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ExecutorServicePerMethodCallThriftServer.java
deleted file mode 100644
index 2504a0a..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ExecutorServicePerMethodCallThriftServer.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package com.nearinfinity.blur.thrift;
-
-/**
- * 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.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TMessage;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.server.THsHaServer;
-import org.apache.thrift.transport.TNonblockingServerTransport;
-import org.apache.thrift.transport.TTransport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ExecutorServicePerMethodCallThriftServer extends THsHaServer {
-
-  private static final Object[] ARGS = new Object[] {};
-  private static final Logger LOGGER = LoggerFactory.getLogger(THsHaServer.class.getName());
-  private Method method;
-
-  public static class Args extends THsHaServer.Args {
-    private int workerThreads = 5;
-    private int stopTimeoutVal = 60;
-    private TimeUnit stopTimeoutUnit = TimeUnit.SECONDS;
-    private ExecutorService executorService = null;
-    private Map<String, ExecutorService> methodCallsToExecutorService;
-
-    public Map<String, ExecutorService> getMethodCallsToExecutorService() {
-      return methodCallsToExecutorService;
-    }
-
-    public void setMethodCallsToExecutorService(Map<String, ExecutorService> methodCallsToExecutorService) {
-      this.methodCallsToExecutorService = methodCallsToExecutorService;
-    }
-
-    public Args(TNonblockingServerTransport transport) {
-      super(transport);
-    }
-
-    public Args workerThreads(int i) {
-      workerThreads = i;
-      return this;
-    }
-
-    public int getWorkerThreads() {
-      return workerThreads;
-    }
-
-    public int getStopTimeoutVal() {
-      return stopTimeoutVal;
-    }
-
-    public Args stopTimeoutVal(int stopTimeoutVal) {
-      this.stopTimeoutVal = stopTimeoutVal;
-      return this;
-    }
-
-    public TimeUnit getStopTimeoutUnit() {
-      return stopTimeoutUnit;
-    }
-
-    public Args stopTimeoutUnit(TimeUnit stopTimeoutUnit) {
-      this.stopTimeoutUnit = stopTimeoutUnit;
-      return this;
-    }
-
-    public ExecutorService getExecutorService() {
-      return executorService;
-    }
-
-    public Args executorService(ExecutorService executorService) {
-      this.executorService = executorService;
-      return this;
-    }
-  }
-
-  private ExecutorService invokerStandard;
-  private Map<String, ExecutorService> methodCallsToExecutorService;
-
-  public ExecutorServicePerMethodCallThriftServer(Args args) {
-    super(args);
-    try {
-      method = FrameBuffer.class.getDeclaredMethod("getInputTransport", new Class[] {});
-      method.setAccessible(true);
-    } catch (SecurityException e) {
-      throw new RuntimeException(e);
-    } catch (NoSuchMethodException e) {
-      throw new RuntimeException(e);
-    }
-    invokerStandard = args.executorService == null ? createInvokerPool(args) : args.executorService;
-    methodCallsToExecutorService = args.methodCallsToExecutorService == null ? new HashMap<String, ExecutorService>() : args.methodCallsToExecutorService;
-  }
-
-  @Override
-  protected boolean requestInvoke(FrameBuffer frameBuffer) {
-    try {
-      String name;
-      try {
-        name = readMethodCall(frameBuffer);
-      } catch (TException e) {
-        LOGGER.error("Unexpected exception while invoking!", e);
-        return false;
-      }
-      Runnable invocation = getRunnable(frameBuffer);
-      ExecutorService executorService = methodCallsToExecutorService.get(name);
-      if (executorService == null) {
-        invokerStandard.execute(invocation);
-      } else {
-        executorService.execute(invocation);
-      }
-      return true;
-    } catch (RejectedExecutionException rx) {
-      LOGGER.warn("ExecutorService rejected execution!", rx);
-      return false;
-    }
-  }
-
-  private String readMethodCall(FrameBuffer frameBuffer) throws TException {
-    TTransport transport = getInputTransport(frameBuffer);
-    TProtocol inProt = inputProtocolFactory_.getProtocol(transport);
-    try {
-      TMessage tMessage = inProt.readMessageBegin();
-      return tMessage.name;
-    } finally {
-      transport.close();
-    }
-
-  }
-
-  private TTransport getInputTransport(FrameBuffer frameBuffer) {
-    try {
-      return (TTransport) method.invoke(frameBuffer, ARGS);
-    } catch (IllegalArgumentException e) {
-      throw new RuntimeException(e);
-    } catch (IllegalAccessException e) {
-      throw new RuntimeException(e);
-    } catch (InvocationTargetException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/MutationHelper.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/MutationHelper.java b/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/MutationHelper.java
deleted file mode 100644
index 639cda3..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/MutationHelper.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.nearinfinity.blur.thrift;
-
-/**
- * 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.List;
-
-import org.apache.hadoop.io.BytesWritable;
-
-import com.nearinfinity.blur.manager.BlurPartitioner;
-import com.nearinfinity.blur.thrift.generated.Record;
-import com.nearinfinity.blur.thrift.generated.RecordMutation;
-import com.nearinfinity.blur.thrift.generated.Row;
-import com.nearinfinity.blur.thrift.generated.RowMutation;
-import com.nearinfinity.blur.utils.BlurConstants;
-import com.nearinfinity.blur.utils.BlurUtil;
-
-public class MutationHelper {
-
-  public static String getShardName(String table, String rowId, int numberOfShards, BlurPartitioner<BytesWritable, ?> blurPartitioner) {
-    BytesWritable key = getKey(rowId);
-    int partition = blurPartitioner.getPartition(key, null, numberOfShards);
-    return BlurUtil.getShardName(BlurConstants.SHARD_PREFIX, partition);
-  }
-
-  public static void validateMutation(RowMutation mutation) {
-    if (mutation == null) {
-      throw new NullPointerException("Mutation can not be null.");
-    }
-    if (mutation.rowId == null) {
-      throw new NullPointerException("Rowid can not be null in mutation.");
-    }
-    if (mutation.table == null) {
-      throw new NullPointerException("Table can not be null in mutation.");
-    }
-  }
-
-  public static BytesWritable getKey(String rowId) {
-    return new BytesWritable(rowId.getBytes());
-  }
-
-  public static Row getRowFromMutations(String id, List<RecordMutation> recordMutations) {
-    Row row = new Row().setId(id);
-    for (RecordMutation mutation : recordMutations) {
-      Record record = mutation.getRecord();
-      switch (mutation.recordMutationType) {
-      case REPLACE_ENTIRE_RECORD:
-        row.addToRecords(record);
-        break;
-      default:
-        throw new RuntimeException("Not supported [" + mutation.recordMutationType + "]");
-      }
-    }
-    return row;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/TableAdmin.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/TableAdmin.java b/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/TableAdmin.java
deleted file mode 100644
index 00f2d32..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/TableAdmin.java
+++ /dev/null
@@ -1,315 +0,0 @@
-package com.nearinfinity.blur.thrift;
-
-/**
- * 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.List;
-import java.util.Map;
-
-import org.apache.thrift.TException;
-import org.apache.zookeeper.ZooKeeper;
-
-import com.nearinfinity.blur.BlurConfiguration;
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.manager.clusterstatus.ClusterStatus;
-import com.nearinfinity.blur.thrift.generated.Blur.Iface;
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.thrift.generated.TableDescriptor;
-import com.nearinfinity.blur.thrift.generated.TableStats;
-
-public abstract class TableAdmin implements Iface {
-
-  private static final Log LOG = LogFactory.getLog(TableAdmin.class);
-  protected ZooKeeper _zookeeper;
-  protected ClusterStatus _clusterStatus;
-  protected BlurConfiguration _configuration;
-
-  @Override
-  public TableStats getTableStats(String table) throws BlurException, TException {
-    return tableStats(table);
-  }
-
-  @Override
-  public boolean isInSafeMode(String cluster) throws BlurException, TException {
-    try {
-      return _clusterStatus.isInSafeMode(true, cluster);
-    } catch (Exception e) {
-      LOG.error("Unknown error during safe mode check of [cluster={0}]", e, cluster);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  @Override
-  public final void createTable(TableDescriptor tableDescriptor) throws BlurException, TException {
-    try {
-      // @todo Remove this once issue #27 is resolved
-      if (tableDescriptor.compressionBlockSize > 32768) {
-        tableDescriptor.compressionBlockSize = 32768;
-      } else if (tableDescriptor.compressionBlockSize < 8192) {
-        tableDescriptor.compressionBlockSize = 8192;
-      }
-      _clusterStatus.createTable(tableDescriptor);
-    } catch (Exception e) {
-      LOG.error("Unknown error during create of [table={0}, tableDescriptor={1}]", e, tableDescriptor.name, tableDescriptor);
-      throw new BException(e.getMessage(), e);
-    }
-    if (tableDescriptor.isEnabled) {
-      enableTable(tableDescriptor.name);
-    }
-  }
-
-  @Override
-  public final void disableTable(String table) throws BlurException, TException {
-    try {
-      String cluster = _clusterStatus.getCluster(false, table);
-      if (cluster == null) {
-        throw new BlurException("Table [" + table + "] not found.", null);
-      }
-      _clusterStatus.disableTable(cluster, table);
-      waitForTheTableToDisable(cluster, table);
-      waitForTheTableToDisengage(cluster, table);
-    } catch (Exception e) {
-      LOG.error("Unknown error during disable of [table={0}]", e, table);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  private void waitForTheTableToDisengage(String cluster, String table) throws BlurException, TException {
-    // LOG.info("Waiting for shards to disengage on table [" + table + "]");
-  }
-
-  private void waitForTheTableToDisable(String cluster, String table) throws BlurException, TException {
-    LOG.info("Waiting for shards to disable on table [" + table + "]");
-    while (true) {
-      if (!_clusterStatus.isEnabled(false, cluster, table)) {
-        return;
-      }
-      try {
-        Thread.sleep(3000);
-      } catch (InterruptedException e) {
-        LOG.error("Unknown error while enabling table [" + table + "]", e);
-        throw new BException("Unknown error while enabling table [" + table + "]", e);
-      }
-    }
-  }
-
-  @Override
-  public final void enableTable(String table) throws BlurException, TException {
-    try {
-      String cluster = _clusterStatus.getCluster(false, table);
-      if (cluster == null) {
-        throw new BlurException("Table [" + table + "] not found.", null);
-      }
-      _clusterStatus.enableTable(cluster, table);
-      waitForTheTableToEnable(cluster, table);
-      waitForTheTableToEngage(cluster, table);
-    } catch (Exception e) {
-      LOG.error("Unknown error during enable of [table={0}]", e, table);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  private void waitForTheTableToEnable(String cluster, String table) throws BlurException {
-    LOG.info("Waiting for shards to engage on table [" + table + "]");
-    while (true) {
-      if (_clusterStatus.isEnabled(false, cluster, table)) {
-        return;
-      }
-      try {
-        Thread.sleep(3000);
-      } catch (InterruptedException e) {
-        LOG.error("Unknown error while enabling table [" + table + "]", e);
-        throw new BException("Unknown error while enabling table [" + table + "]", e);
-      }
-    }
-  }
-
-  private void waitForTheTableToEngage(String cluster, String table) throws BlurException, TException {
-    TableDescriptor describe = describe(table);
-    int shardCount = describe.shardCount;
-    LOG.info("Waiting for shards to engage on table [" + table + "]");
-    while (true) {
-      try {
-        Thread.sleep(3000);
-      } catch (InterruptedException e) {
-        LOG.error("Unknown error while engaging table [" + table + "]", e);
-        throw new BException("Unknown error while engaging table [" + table + "]", e);
-      }
-      try {
-        Map<String, String> shardServerLayout = shardServerLayout(table);
-        LOG.info("Shards [" + shardServerLayout.size() + "/" + shardCount + "] of table [" + table + "] engaged");
-        if (shardServerLayout.size() == shardCount) {
-          return;
-        }
-      } catch (BlurException e) {
-        LOG.info("Stilling waiting", e);
-      } catch (TException e) {
-        LOG.info("Stilling waiting", e);
-      }
-    }
-  }
-
-  @Override
-  public final void removeTable(String table, boolean deleteIndexFiles) throws BlurException, TException {
-    try {
-      String cluster = _clusterStatus.getCluster(false, table);
-      if (cluster == null) {
-        throw new BlurException("Table [" + table + "] not found.", null);
-      }
-      _clusterStatus.removeTable(cluster, table, deleteIndexFiles);
-    } catch (Exception e) {
-      LOG.error("Unknown error during remove of [table={0}]", e, table);
-      throw new BException(e.getMessage(), e);
-    }
-  }
-
-  public boolean isTableEnabled(boolean useCache, String cluster, String table) {
-    return _clusterStatus.isEnabled(useCache, cluster, table);
-  }
-
-  public void checkTable(String table) throws BlurException {
-    if (table == null) {
-      throw new BlurException("Table cannot be null.", null);
-    }
-    String cluster = _clusterStatus.getCluster(true, table);
-    if (cluster == null) {
-      throw new BlurException("Table [" + table + "] does not exist", null);
-    }
-    checkTable(cluster, table);
-  }
-
-  public void checkTable(String cluster, String table) throws BlurException {
-    if (inSafeMode(true, table)) {
-      throw new BlurException("Cluster for [" + table + "] is in safe mode", null);
-    }
-    if (tableExists(true, cluster, table)) {
-      if (isTableEnabled(true, cluster, table)) {
-        return;
-      }
-      throw new BlurException("Table [" + table + "] exists, but is not enabled", null);
-    } else {
-      throw new BlurException("Table [" + table + "] does not exist", null);
-    }
-  }
-
-  public void checkForUpdates(String table) throws BlurException {
-    String cluster = _clusterStatus.getCluster(true, table);
-    if (cluster == null) {
-      throw new BlurException("Table [" + table + "] does not exist", null);
-    }
-    checkForUpdates(cluster, table);
-  }
-
-  public void checkForUpdates(String cluster, String table) throws BlurException {
-    if (_clusterStatus.isReadOnly(true, cluster, table)) {
-      throw new BlurException("Table [" + table + "] in cluster [" + cluster + "] is read only.", null);
-    }
-  }
-
-  @Override
-  public final List<String> controllerServerList() throws BlurException, TException {
-    try {
-      return _clusterStatus.getControllerServerList();
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get a controller list.", e);
-      throw new BException("Unknown error while trying to get a controller list.", e);
-    }
-  }
-
-  @Override
-  public final List<String> shardServerList(String cluster) throws BlurException, TException {
-    try {
-      return _clusterStatus.getShardServerList(cluster);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get a shard server list.", e);
-      throw new BException("Unknown error while trying to get a shard server list.", e);
-    }
-  }
-
-  @Override
-  public final List<String> shardClusterList() throws BlurException, TException {
-    try {
-      return _clusterStatus.getClusterList(true);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get a cluster list.", e);
-      throw new BException("Unknown error while trying to get a cluster list.", e);
-    }
-  }
-
-  @Override
-  public final TableDescriptor describe(final String table) throws BlurException, TException {
-    try {
-      String cluster = _clusterStatus.getCluster(true, table);
-      if (cluster == null) {
-        throw new BlurException("Table [" + table + "] not found.", null);
-      }
-      return _clusterStatus.getTableDescriptor(true, cluster, table);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to describe a table [" + table + "].", e);
-      throw new BException("Unknown error while trying to describe a table [" + table + "].", e);
-    }
-  }
-
-  @Override
-  public final List<String> tableListByCluster(String cluster) throws BlurException, TException {
-    try {
-      return _clusterStatus.getTableList(true, cluster);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get a table list by cluster [" + cluster + "].", e);
-      throw new BException("Unknown error while trying to get a table list by cluster [" + cluster + "].", e);
-    }
-  }
-
-  @Override
-  public final List<String> tableList() throws BlurException, TException {
-    try {
-      return _clusterStatus.getTableList(true);
-    } catch (Exception e) {
-      LOG.error("Unknown error while trying to get a table list.", e);
-      throw new BException("Unknown error while trying to get a table list.", e);
-    }
-  }
-
-  private boolean inSafeMode(boolean useCache, String table) throws BlurException {
-    String cluster = _clusterStatus.getCluster(useCache, table);
-    if (cluster == null) {
-      throw new BlurException("Table [" + table + "] not found.", null);
-    }
-    return _clusterStatus.isInSafeMode(useCache, cluster);
-  }
-
-  public boolean tableExists(boolean useCache, String cluster, String table) {
-    return _clusterStatus.exists(useCache, cluster, table);
-  }
-
-  public ClusterStatus getClusterStatus() {
-    return _clusterStatus;
-  }
-
-  public void setClusterStatus(ClusterStatus clusterStatus) {
-    _clusterStatus = clusterStatus;
-  }
-
-  public void setZookeeper(ZooKeeper zookeeper) {
-    _zookeeper = zookeeper;
-  }
-
-  @Override
-  public Map<String, String> configuration() throws BlurException, TException {
-    return _configuration.getProperties();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftBlurControllerServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftBlurControllerServer.java b/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftBlurControllerServer.java
deleted file mode 100644
index 574d176..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftBlurControllerServer.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package com.nearinfinity.blur.thrift;
-
-/**
- * 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.utils.BlurConstants.BLUR_CONTROLLER_BIND_ADDRESS;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_BIND_PORT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_CACHE_MAX_QUERYCACHE_ELEMENTS;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_CACHE_MAX_TIMETOLIVE;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_HOSTNAME;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_REMOTE_FETCH_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_DEFAULT_DELAY;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_FETCH_DELAY;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_MAX_DEFAULT_DELAY;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_MAX_DEFAULT_RETRIES;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_MAX_FETCH_DELAY;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_MAX_FETCH_RETRIES;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_MAX_MUTATE_DELAY;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_MAX_MUTATE_RETRIES;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_RETRY_MUTATE_DELAY;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_SERVER_REMOTE_THREAD_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_SERVER_THRIFT_THREAD_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_GUI_CONTROLLER_PORT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_GUI_SHARD_PORT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_BIND_PORT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_ZOOKEEPER_CONNECTION;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_ZOOKEEPER_SYSTEM_TIME_TOLERANCE;
-import static com.nearinfinity.blur.utils.BlurUtil.quietClose;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.zookeeper.ZooKeeper;
-
-import com.nearinfinity.blur.BlurConfiguration;
-import com.nearinfinity.blur.concurrent.SimpleUncaughtExceptionHandler;
-import com.nearinfinity.blur.concurrent.ThreadWatcher;
-import com.nearinfinity.blur.gui.HttpJettyServer;
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.manager.BlurQueryChecker;
-import com.nearinfinity.blur.manager.clusterstatus.ZookeeperClusterStatus;
-import com.nearinfinity.blur.manager.indexserver.BlurServerShutDown;
-import com.nearinfinity.blur.manager.indexserver.BlurServerShutDown.BlurShutdown;
-import com.nearinfinity.blur.metrics.BlurMetrics;
-import com.nearinfinity.blur.thrift.generated.Blur.Iface;
-import com.nearinfinity.blur.utils.BlurUtil;
-import com.nearinfinity.blur.zookeeper.ZkUtils;
-
-public class ThriftBlurControllerServer extends ThriftServer {
-
-  private static final Log LOG = LogFactory.getLog(ThriftBlurControllerServer.class);
-
-  public static void main(String[] args) throws Exception {
-    int serverIndex = getServerIndex(args);
-    LOG.info("Setting up Controller Server");
-    BlurConfiguration configuration = new BlurConfiguration();
-    ThriftServer server = createServer(serverIndex, configuration);
-    server.start();
-  }
-
-  public static ThriftServer createServer(int serverIndex, BlurConfiguration configuration) throws Exception {
-    Thread.setDefaultUncaughtExceptionHandler(new SimpleUncaughtExceptionHandler());
-    String bindAddress = configuration.get(BLUR_CONTROLLER_BIND_ADDRESS);
-    int bindPort = configuration.getInt(BLUR_CONTROLLER_BIND_PORT, -1);
-    bindPort += serverIndex;
-
-    LOG.info("Shard Server using index [{0}] bind address [{1}]", serverIndex, bindAddress + ":" + bindPort);
-
-    Configuration config = new Configuration();
-    BlurMetrics blurMetrics = new BlurMetrics(config);
-
-    String nodeName = ThriftBlurShardServer.getNodeName(configuration, BLUR_CONTROLLER_HOSTNAME);
-    nodeName = nodeName + ":" + bindPort;
-    String zkConnectionStr = isEmpty(configuration.get(BLUR_ZOOKEEPER_CONNECTION), BLUR_ZOOKEEPER_CONNECTION);
-
-    BlurQueryChecker queryChecker = new BlurQueryChecker(configuration);
-
-    final ZooKeeper zooKeeper = ZkUtils.newZooKeeper(zkConnectionStr);
-    ZookeeperSystemTime.checkSystemTime(zooKeeper, configuration.getLong(BLUR_ZOOKEEPER_SYSTEM_TIME_TOLERANCE, 3000));
-
-    BlurUtil.setupZookeeper(zooKeeper);
-
-    final ZookeeperClusterStatus clusterStatus = new ZookeeperClusterStatus(zooKeeper);
-
-    BlurControllerServer.BlurClient client = new BlurControllerServer.BlurClientRemote();
-
-    final BlurControllerServer controllerServer = new BlurControllerServer();
-    controllerServer.setClient(client);
-    controllerServer.setClusterStatus(clusterStatus);
-    controllerServer.setZookeeper(zooKeeper);
-    controllerServer.setNodeName(nodeName);
-    controllerServer.setRemoteFetchCount(configuration.getInt(BLUR_CONTROLLER_REMOTE_FETCH_COUNT, 100));
-    controllerServer.setMaxQueryCacheElements(configuration.getInt(BLUR_CONTROLLER_CACHE_MAX_QUERYCACHE_ELEMENTS, 128));
-    controllerServer.setMaxTimeToLive(configuration.getLong(BLUR_CONTROLLER_CACHE_MAX_TIMETOLIVE, TimeUnit.MINUTES.toMillis(1)));
-    controllerServer.setQueryChecker(queryChecker);
-    controllerServer.setThreadCount(configuration.getInt(BLUR_CONTROLLER_SERVER_REMOTE_THREAD_COUNT, 64));
-    controllerServer.setMaxFetchRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_FETCH_RETRIES, 3));
-    controllerServer.setMaxMutateRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_MUTATE_RETRIES, 3));
-    controllerServer.setMaxDefaultRetries(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_DEFAULT_RETRIES, 3));
-    controllerServer.setFetchDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_FETCH_DELAY, 500));
-    controllerServer.setMutateDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MUTATE_DELAY, 500));
-    controllerServer.setDefaultDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_DEFAULT_DELAY, 500));
-    controllerServer.setMaxFetchDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_FETCH_DELAY, 2000));
-    controllerServer.setMaxMutateDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_MUTATE_DELAY, 2000));
-    controllerServer.setMaxDefaultDelay(configuration.getInt(BLUR_CONTROLLER_RETRY_MAX_DEFAULT_DELAY, 2000));
-
-    controllerServer.init();
-
-    Iface iface = BlurUtil.recordMethodCallsAndAverageTimes(blurMetrics, controllerServer, Iface.class);
-
-    int threadCount = configuration.getInt(BLUR_CONTROLLER_SERVER_THRIFT_THREAD_COUNT, 32);
-
-    final ThriftBlurControllerServer server = new ThriftBlurControllerServer();
-    server.setNodeName(nodeName);
-    server.setConfiguration(configuration);
-    server.setBindAddress(bindAddress);
-    server.setBindPort(bindPort);
-    server.setThreadCount(threadCount);
-    server.setIface(iface);
-
-    int baseGuiPort = Integer.parseInt(configuration.get(BLUR_GUI_CONTROLLER_PORT));
-    final HttpJettyServer httpServer;
-    if (baseGuiPort > 0) {
-      int webServerPort = baseGuiPort + serverIndex;
-      // TODO: this got ugly, there has to be a better way to handle all these
-      // params
-      // without reversing the mvn dependancy and making blur-gui on top.
-      httpServer = new HttpJettyServer(bindPort, webServerPort, configuration.getInt(BLUR_CONTROLLER_BIND_PORT, -1), configuration.getInt(BLUR_SHARD_BIND_PORT, -1),
-          configuration.getInt(BLUR_GUI_CONTROLLER_PORT, -1), configuration.getInt(BLUR_GUI_SHARD_PORT, -1), "controller", blurMetrics);
-    } else {
-      httpServer = null;
-    }
-
-    // This will shutdown the server when the correct path is set in zk
-    BlurShutdown shutdown = new BlurShutdown() {
-      @Override
-      public void shutdown() {
-        ThreadWatcher threadWatcher = ThreadWatcher.instance();
-        quietClose(server, controllerServer, clusterStatus, zooKeeper, threadWatcher, httpServer);
-      }
-    };
-    server.setShutdown(shutdown);
-    new BlurServerShutDown().register(shutdown, zooKeeper);
-    return server;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftBlurShardServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftBlurShardServer.java b/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftBlurShardServer.java
deleted file mode 100644
index a65c4f5..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftBlurShardServer.java
+++ /dev/null
@@ -1,264 +0,0 @@
-package com.nearinfinity.blur.thrift;
-
-/**
- * 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.utils.BlurConstants.BLUR_CLUSTER_NAME;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_CONTROLLER_BIND_PORT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_GUI_CONTROLLER_PORT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_GUI_SHARD_PORT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_INDEXMANAGER_SEARCH_THREAD_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_MAX_CLAUSE_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_BIND_ADDRESS;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_BIND_PORT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_BLOCKCACHE_DIRECT_MEMORY_ALLOCATION;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_BLOCKCACHE_SLAB_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_CACHE_MAX_QUERYCACHE_ELEMENTS;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_CACHE_MAX_TIMETOLIVE;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_DATA_FETCH_THREAD_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_FILTER_CACHE_CLASS;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_HOSTNAME;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_INDEX_WARMUP_CLASS;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_OPENER_THREAD_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_SAFEMODEDELAY;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_SERVER_THRIFT_THREAD_COUNT;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_TIME_BETWEEN_COMMITS;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_SHARD_TIME_BETWEEN_REFRESHS;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_ZOOKEEPER_CONNECTION;
-import static com.nearinfinity.blur.utils.BlurConstants.BLUR_ZOOKEEPER_SYSTEM_TIME_TOLERANCE;
-import static com.nearinfinity.blur.utils.BlurUtil.quietClose;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.lucene.index.IndexDeletionPolicy;
-import org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.Code;
-import org.apache.zookeeper.ZooKeeper;
-
-import com.nearinfinity.blur.BlurConfiguration;
-import com.nearinfinity.blur.concurrent.SimpleUncaughtExceptionHandler;
-import com.nearinfinity.blur.concurrent.ThreadWatcher;
-import com.nearinfinity.blur.gui.HttpJettyServer;
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.manager.BlurFilterCache;
-import com.nearinfinity.blur.manager.BlurQueryChecker;
-import com.nearinfinity.blur.manager.DefaultBlurFilterCache;
-import com.nearinfinity.blur.manager.IndexManager;
-import com.nearinfinity.blur.manager.clusterstatus.ZookeeperClusterStatus;
-import com.nearinfinity.blur.manager.indexserver.BlurIndexWarmup;
-import com.nearinfinity.blur.manager.indexserver.BlurServerShutDown;
-import com.nearinfinity.blur.manager.indexserver.BlurServerShutDown.BlurShutdown;
-import com.nearinfinity.blur.manager.indexserver.DefaultBlurIndexWarmup;
-import com.nearinfinity.blur.manager.indexserver.DistributedIndexServer;
-import com.nearinfinity.blur.manager.writer.BlurIndexRefresher;
-import com.nearinfinity.blur.metrics.BlurMetrics;
-import com.nearinfinity.blur.store.BufferStore;
-import com.nearinfinity.blur.store.blockcache.BlockCache;
-import com.nearinfinity.blur.store.blockcache.BlockDirectory;
-import com.nearinfinity.blur.store.blockcache.BlockDirectoryCache;
-import com.nearinfinity.blur.store.blockcache.Cache;
-import com.nearinfinity.blur.thrift.generated.Blur.Iface;
-import com.nearinfinity.blur.utils.BlurUtil;
-import com.nearinfinity.blur.zookeeper.ZkUtils;
-
-public class ThriftBlurShardServer extends ThriftServer {
-
-  private static final Log LOG = LogFactory.getLog(ThriftBlurShardServer.class);
-
-  public static void main(String[] args) throws Exception {
-    int serverIndex = getServerIndex(args);
-    LOG.info("Setting up Shard Server");
-
-    Thread.setDefaultUncaughtExceptionHandler(new SimpleUncaughtExceptionHandler());
-    BlurConfiguration configuration = new BlurConfiguration();
-
-    ThriftServer server = createServer(serverIndex, configuration);
-    server.start();
-  }
-
-  public static ThriftServer createServer(int serverIndex, BlurConfiguration configuration) throws Exception {
-    // setup block cache
-    // 134,217,728 is the slab size, therefore there are 16,384 blocks
-    // in a slab when using a block size of 8,192
-    int numberOfBlocksPerSlab = 16384;
-    int blockSize = BlockDirectory.BLOCK_SIZE;
-    int slabCount = configuration.getInt(BLUR_SHARD_BLOCKCACHE_SLAB_COUNT, 1);
-    Cache cache;
-    Configuration config = new Configuration();
-    BlurMetrics blurMetrics = new BlurMetrics(config);
-    if (slabCount >= 1) {
-      BlockCache blockCache;
-      boolean directAllocation = configuration.getBoolean(BLUR_SHARD_BLOCKCACHE_DIRECT_MEMORY_ALLOCATION, true);
-
-      int slabSize = numberOfBlocksPerSlab * blockSize;
-      LOG.info("Number of slabs of block cache [{0}] with direct memory allocation set to [{1}]", slabCount, directAllocation);
-      LOG.info("Block cache target memory usage, slab size of [{0}] will allocate [{1}] slabs and use ~[{2}] bytes", slabSize, slabCount, ((long) slabCount * (long) slabSize));
-
-      BufferStore.init(configuration, blurMetrics);
-
-      try {
-        long totalMemory = (long) slabCount * (long) numberOfBlocksPerSlab * (long) blockSize;
-        blockCache = new BlockCache(blurMetrics, directAllocation, totalMemory, slabSize, blockSize);
-      } catch (OutOfMemoryError e) {
-        if ("Direct buffer memory".equals(e.getMessage())) {
-          System.err
-              .println("The max direct memory is too low.  Either increase by setting (-XX:MaxDirectMemorySize=<size>g -XX:+UseLargePages) or disable direct allocation by (blur.shard.blockcache.direct.memory.allocation=false) in blur-site.properties");
-          System.exit(1);
-        }
-        throw e;
-      }
-      cache = new BlockDirectoryCache(blockCache, blurMetrics);
-    } else {
-      cache = BlockDirectory.NO_CACHE;
-    }
-
-    String bindAddress = configuration.get(BLUR_SHARD_BIND_ADDRESS);
-    int bindPort = configuration.getInt(BLUR_SHARD_BIND_PORT, -1);
-    bindPort += serverIndex;
-
-    LOG.info("Shard Server using index [{0}] bind address [{1}]", serverIndex, bindAddress + ":" + bindPort);
-
-    String nodeNameHostName = getNodeName(configuration, BLUR_SHARD_HOSTNAME);
-    String nodeName = nodeNameHostName + ":" + bindPort;
-    String zkConnectionStr = isEmpty(configuration.get(BLUR_ZOOKEEPER_CONNECTION), BLUR_ZOOKEEPER_CONNECTION);
-
-    BlurQueryChecker queryChecker = new BlurQueryChecker(configuration);
-
-    final ZooKeeper zooKeeper = ZkUtils.newZooKeeper(zkConnectionStr);
-    try {
-      ZookeeperSystemTime.checkSystemTime(zooKeeper, configuration.getLong(BLUR_ZOOKEEPER_SYSTEM_TIME_TOLERANCE, 3000));
-    } catch (KeeperException e) {
-      if (e.code() == Code.CONNECTIONLOSS) {
-        System.err.println("Cannot connect zookeeper to [" + zkConnectionStr + "]");
-        System.exit(1);
-      }
-    }
-
-    BlurUtil.setupZookeeper(zooKeeper, configuration.get(BLUR_CLUSTER_NAME));
-
-    final ZookeeperClusterStatus clusterStatus = new ZookeeperClusterStatus(zooKeeper);
-
-    final BlurIndexRefresher refresher = new BlurIndexRefresher();
-    refresher.init();
-
-    BlurFilterCache filterCache = getFilterCache(configuration);
-    BlurIndexWarmup indexWarmup = getIndexWarmup(configuration);
-    IndexDeletionPolicy indexDeletionPolicy = new KeepOnlyLastCommitDeletionPolicy();
-
-    final DistributedIndexServer indexServer = new DistributedIndexServer();
-    indexServer.setBlurMetrics(blurMetrics);
-    indexServer.setCache(cache);
-    indexServer.setClusterStatus(clusterStatus);
-    indexServer.setConfiguration(config);
-    indexServer.setNodeName(nodeName);
-    indexServer.setRefresher(refresher);
-    indexServer.setShardOpenerThreadCount(configuration.getInt(BLUR_SHARD_OPENER_THREAD_COUNT, 16));
-    indexServer.setZookeeper(zooKeeper);
-    indexServer.setFilterCache(filterCache);
-    indexServer.setSafeModeDelay(configuration.getLong(BLUR_SHARD_SAFEMODEDELAY, 60000));
-    indexServer.setWarmup(indexWarmup);
-    indexServer.setIndexDeletionPolicy(indexDeletionPolicy);
-    indexServer.setTimeBetweenCommits(configuration.getLong(BLUR_SHARD_TIME_BETWEEN_COMMITS, 60000));
-    indexServer.setTimeBetweenRefreshs(configuration.getLong(BLUR_SHARD_TIME_BETWEEN_REFRESHS, 500));
-    indexServer.init();
-
-    final IndexManager indexManager = new IndexManager();
-    indexManager.setIndexServer(indexServer);
-    indexManager.setMaxClauseCount(configuration.getInt(BLUR_MAX_CLAUSE_COUNT, 1024));
-    indexManager.setThreadCount(configuration.getInt(BLUR_INDEXMANAGER_SEARCH_THREAD_COUNT, 32));
-    indexManager.setBlurMetrics(blurMetrics);
-    indexManager.setFilterCache(filterCache);
-    indexManager.init();
-
-    final BlurShardServer shardServer = new BlurShardServer();
-    shardServer.setIndexServer(indexServer);
-    shardServer.setIndexManager(indexManager);
-    shardServer.setZookeeper(zooKeeper);
-    shardServer.setClusterStatus(clusterStatus);
-    shardServer.setDataFetchThreadCount(configuration.getInt(BLUR_SHARD_DATA_FETCH_THREAD_COUNT, 8));
-    shardServer.setMaxQueryCacheElements(configuration.getInt(BLUR_SHARD_CACHE_MAX_QUERYCACHE_ELEMENTS, 128));
-    shardServer.setMaxTimeToLive(configuration.getLong(BLUR_SHARD_CACHE_MAX_TIMETOLIVE, TimeUnit.MINUTES.toMillis(1)));
-    shardServer.setQueryChecker(queryChecker);
-    shardServer.init();
-
-    Iface iface = BlurUtil.recordMethodCallsAndAverageTimes(blurMetrics, shardServer, Iface.class);
-
-    int threadCount = configuration.getInt(BLUR_SHARD_SERVER_THRIFT_THREAD_COUNT, 32);
-
-    final ThriftBlurShardServer server = new ThriftBlurShardServer();
-    server.setNodeName(nodeName);
-    server.setBindAddress(bindAddress);
-    server.setBindPort(bindPort);
-    server.setThreadCount(threadCount);
-    server.setIface(iface);
-    server.setConfiguration(configuration);
-
-    int baseGuiPort = Integer.parseInt(configuration.get(BLUR_GUI_SHARD_PORT));
-    final HttpJettyServer httpServer;
-    if (baseGuiPort > 0) {
-      int webServerPort = baseGuiPort + serverIndex;
-
-      // TODO: this got ugly, there has to be a better way to handle all these
-      // params
-      // without reversing the mvn dependancy and making blur-gui on top.
-      httpServer = new HttpJettyServer(bindPort, webServerPort, configuration.getInt(BLUR_CONTROLLER_BIND_PORT, -1), configuration.getInt(BLUR_SHARD_BIND_PORT, -1),
-          configuration.getInt(BLUR_GUI_CONTROLLER_PORT, -1), configuration.getInt(BLUR_GUI_SHARD_PORT, -1), "shard", blurMetrics);
-    } else {
-      httpServer = null;
-    }
-
-    // This will shutdown the server when the correct path is set in zk
-    BlurShutdown shutdown = new BlurShutdown() {
-      @Override
-      public void shutdown() {
-        ThreadWatcher threadWatcher = ThreadWatcher.instance();
-        quietClose(refresher, server, shardServer, indexManager, indexServer, threadWatcher, clusterStatus, zooKeeper, httpServer);
-      }
-    };
-    server.setShutdown(shutdown);
-    new BlurServerShutDown().register(shutdown, zooKeeper);
-    return server;
-  }
-
-  private static BlurFilterCache getFilterCache(BlurConfiguration configuration) {
-    String _blurFilterCacheClass = configuration.get(BLUR_SHARD_FILTER_CACHE_CLASS);
-    if (_blurFilterCacheClass != null) {
-      try {
-        Class<?> clazz = Class.forName(_blurFilterCacheClass);
-        return (BlurFilterCache) clazz.newInstance();
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-    return new DefaultBlurFilterCache();
-  }
-
-  private static BlurIndexWarmup getIndexWarmup(BlurConfiguration configuration) {
-    String _blurFilterCacheClass = configuration.get(BLUR_SHARD_INDEX_WARMUP_CLASS);
-    if (_blurFilterCacheClass != null) {
-      try {
-        Class<?> clazz = Class.forName(_blurFilterCacheClass);
-        return (BlurIndexWarmup) clazz.newInstance();
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-    return new DefaultBlurIndexWarmup();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftServer.java b/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftServer.java
deleted file mode 100644
index adec2a8..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ThriftServer.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package com.nearinfinity.blur.thrift;
-
-/**
- * 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.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-
-import org.apache.thrift.server.TServer;
-import org.apache.thrift.transport.TNonblockingServerSocket;
-import org.apache.thrift.transport.TTransportException;
-
-import com.nearinfinity.blur.BlurConfiguration;
-import com.nearinfinity.blur.concurrent.Executors;
-import com.nearinfinity.blur.log.Log;
-import com.nearinfinity.blur.log.LogFactory;
-import com.nearinfinity.blur.manager.indexserver.BlurServerShutDown.BlurShutdown;
-import com.nearinfinity.blur.thrift.ExecutorServicePerMethodCallThriftServer.Args;
-import com.nearinfinity.blur.thrift.generated.Blur;
-import com.nearinfinity.blur.thrift.generated.Blur.Iface;
-
-public class ThriftServer {
-
-  private static final Log LOG = LogFactory.getLog(ThriftServer.class);
-
-  private String _nodeName;
-  private Iface _iface;
-  private TServer _server;
-  private boolean _closed;
-  private BlurConfiguration _configuration;
-  private int _threadCount;
-  private int _bindPort;
-  private String _bindAddress;
-  private BlurShutdown _shutdown;
-  private ExecutorService _executorService;
-  private ExecutorService _queryExexutorService;
-  private ExecutorService _mutateExecutorService;
-
-  public synchronized void close() {
-    if (!_closed) {
-      _closed = true;
-      _shutdown.shutdown();
-      _server.stop();
-      _executorService.shutdownNow();
-      _queryExexutorService.shutdownNow();
-      _mutateExecutorService.shutdownNow();
-    }
-  }
-
-  protected static int getServerIndex(String[] args) {
-    for (int i = 0; i < args.length; i++) {
-      if ("-s".equals(args[i])) {
-        if (i + 1 < args.length) {
-          return Integer.parseInt(args[i + 1]);
-        }
-      }
-    }
-    return 0;
-  }
-
-  public void start() throws TTransportException {
-    Blur.Processor<Blur.Iface> processor = new Blur.Processor<Blur.Iface>(_iface);
-    TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(getBindInetSocketAddress(_configuration));
-
-    Args args = new Args(serverTransport);
-    args.processor(processor);
-    _executorService = Executors.newThreadPool("thrift-processors", _threadCount);
-    args.executorService(_executorService);
-    Map<String, ExecutorService> methodCallsToExecutorService = new HashMap<String, ExecutorService>();
-    _mutateExecutorService = Executors.newThreadPool("thrift-processors-mutate", _threadCount);
-    methodCallsToExecutorService.put("mutate", _mutateExecutorService);
-    methodCallsToExecutorService.put("mutateBatch", _mutateExecutorService);
-    _queryExexutorService = Executors.newThreadPool("thrift-processors-query", _threadCount);
-    methodCallsToExecutorService.put("query", _queryExexutorService);
-    args.setMethodCallsToExecutorService(methodCallsToExecutorService);
-    _server = new ExecutorServicePerMethodCallThriftServer(args);
-    LOG.info("Starting server [{0}]", _nodeName);
-    _server.serve();
-  }
-
-  public InetSocketAddress getBindInetSocketAddress(BlurConfiguration configuration) {
-    return new InetSocketAddress(_bindAddress, _bindPort);
-  }
-
-  public static String isEmpty(String str, String name) {
-    if (str == null || str.trim().isEmpty()) {
-      throw new IllegalArgumentException("Property [" + name + "] is missing or blank.");
-    }
-    return str;
-  }
-
-  public Iface getIface() {
-    return _iface;
-  }
-
-  public void setIface(Iface iface) {
-    this._iface = iface;
-  }
-
-  public String getNodeName() {
-    return _nodeName;
-  }
-
-  public void setNodeName(String nodeName) {
-    this._nodeName = nodeName;
-  }
-
-  public void setConfiguration(BlurConfiguration configuration) {
-    this._configuration = configuration;
-  }
-
-  public static String getNodeName(BlurConfiguration configuration, String hostNameProperty) throws UnknownHostException {
-    String hostName = configuration.get(hostNameProperty);
-    if (hostName == null) {
-      hostName = "";
-    }
-    hostName = hostName.trim();
-    if (hostName.isEmpty()) {
-      return InetAddress.getLocalHost().getHostName();
-    }
-    return hostName;
-  }
-
-  public void setBindPort(int bindPort) {
-    _bindPort = bindPort;
-  }
-
-  public void setBindAddress(String bindAddress) {
-    _bindAddress = bindAddress;
-  }
-
-  public void setThreadCount(int threadCount) {
-    this._threadCount = threadCount;
-  }
-
-  public BlurShutdown getShutdown() {
-    return _shutdown;
-  }
-
-  public void setShutdown(BlurShutdown shutdown) {
-    this._shutdown = shutdown;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ZookeeperSystemTime.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ZookeeperSystemTime.java b/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ZookeeperSystemTime.java
deleted file mode 100644
index 1099429..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/thrift/ZookeeperSystemTime.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.nearinfinity.blur.thrift;
-
-/**
- * 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.UUID;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.data.Stat;
-
-import com.nearinfinity.blur.thrift.generated.BlurException;
-import com.nearinfinity.blur.zookeeper.ZkUtils;
-
-public class ZookeeperSystemTime {
-  public static void main(String[] args) throws InterruptedException, KeeperException, IOException, BlurException {
-    final ZooKeeper zooKeeper = ZkUtils.newZooKeeper("localhost");
-    long tolerance = 3000;
-    checkSystemTime(zooKeeper, tolerance);
-  }
-
-  public static void checkSystemTime(ZooKeeper zooKeeper, long tolerance) throws KeeperException, InterruptedException, BlurException {
-    String path = zooKeeper.create("/" + UUID.randomUUID().toString(), null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
-    long now = System.currentTimeMillis();
-    Stat stat = zooKeeper.exists(path, false);
-    zooKeeper.delete(path, -1);
-    long ctime = stat.getCtime();
-
-    long low = now - tolerance;
-    long high = now + tolerance;
-    if (!(low <= ctime && ctime <= high)) {
-      throw new BlurException("The system time is too far out of sync with Zookeeper, check your system time and try again.", null);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurConstants.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurConstants.java b/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurConstants.java
deleted file mode 100644
index cb424f3..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurConstants.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.nearinfinity.blur.utils;
-
-/**
- * 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.Comparator;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Field.Index;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.index.Term;
-
-import com.nearinfinity.blur.BlurConfiguration;
-import com.nearinfinity.blur.manager.results.BlurResultComparator;
-import com.nearinfinity.blur.manager.results.BlurResultPeekableIteratorComparator;
-import com.nearinfinity.blur.manager.results.PeekableIterator;
-import com.nearinfinity.blur.thrift.generated.BlurResult;
-
-public class BlurConstants {
-
-  public static final String CONTROLLER = "controller";
-  public static final String SHARD = "shard";
-  public static final String SHARD_PREFIX = "shard-";
-  public static final Comparator<? super PeekableIterator<BlurResult>> HITS_PEEKABLE_ITERATOR_COMPARATOR = new BlurResultPeekableIteratorComparator();
-  public static final Comparator<? super BlurResult> HITS_COMPARATOR = new BlurResultComparator();
-
-  public static final String PRIME_DOC = "_prime_";
-  public static final String PRIME_DOC_VALUE = "true";
-  public static final String ROW_ID = "rowid";
-  public static final String RECORD_ID = "recordid";
-  public static final String SUPER = "super";
-  public static final String SEP = ".";
-
-  public static final String BLUR_TABLE_PATH = "blur.table.path";
-  public static final String BLUR_ZOOKEEPER_CONNECTION = "blur.zookeeper.connection";
-  public static final String BLUR_SHARD_HOSTNAME = "blur.shard.hostname";
-  public static final String BLUR_SHARD_BIND_PORT = "blur.shard.bind.port";
-  public static final String BLUR_SHARD_BIND_ADDRESS = "blur.shard.bind.address";
-  public static final String BLUR_SHARD_BLOCKCACHE_DIRECT_MEMORY_ALLOCATION = "blur.shard.blockcache.direct.memory.allocation";
-  public static final String BLUR_SHARD_BLOCKCACHE_SLAB_COUNT = "blur.shard.blockcache.slab.count";
-  public static final String BLUR_SHARD_SAFEMODEDELAY = "blur.shard.safemodedelay";
-  public static final String BLUR_CONTROLLER_HOSTNAME = "blur.controller.hostname";
-  public static final String BLUR_CONTROLLER_BIND_PORT = "blur.controller.bind.port";
-  public static final String BLUR_CONTROLLER_BIND_ADDRESS = "blur.controller.bind.address";
-  public static final String BLUR_QUERY_MAX_ROW_FETCH = "blur.query.max.row.fetch";
-  public static final String BLUR_QUERY_MAX_RECORD_FETCH = "blur.query.max.record.fetch";
-  public static final String BLUR_QUERY_MAX_RESULTS_FETCH = "blur.query.max.results.fetch";
-
-  public static final String BLUR_SHARD_SERVER_THRIFT_THREAD_COUNT = "blur.shard.server.thrift.thread.count";
-  public static final String BLUR_SHARD_CACHE_MAX_TIMETOLIVE = "blur.shard.cache.max.timetolive";
-  public static final String BLUR_SHARD_FILTER_CACHE_CLASS = "blur.shard.filter.cache.class";
-  public static final String BLUR_SHARD_INDEX_WARMUP_CLASS = "blur.shard.index.warmup.class";
-  public static final String BLUR_INDEXMANAGER_SEARCH_THREAD_COUNT = "blur.indexmanager.search.thread.count";
-  public static final String BLUR_SHARD_DATA_FETCH_THREAD_COUNT = "blur.shard.data.fetch.thread.count";
-  public static final String BLUR_MAX_CLAUSE_COUNT = "blur.max.clause.count";
-  public static final String BLUR_SHARD_CACHE_MAX_QUERYCACHE_ELEMENTS = "blur.shard.cache.max.querycache.elements";
-  public static final String BLUR_SHARD_OPENER_THREAD_COUNT = "blur.shard.opener.thread.count";
-  public static final String BLUR_SHARD_INDEX_DELETION_POLICY_MAXAGE = "blur.shard.index.deletion.policy.maxage";
-  public static final String BLUR_ZOOKEEPER_SYSTEM_TIME_TOLERANCE = "blur.zookeeper.system.time.tolerance";
-
-  public static final String BLUR_SHARD_TIME_BETWEEN_COMMITS = "blur.shard.time.between.commits";
-  public static final String BLUR_SHARD_TIME_BETWEEN_REFRESHS = "blur.shard.time.between.refreshs";
-
-  public static final String BLUR_CONTROLLER_SERVER_THRIFT_THREAD_COUNT = "blur.controller.server.thrift.thread.count";
-  public static final String BLUR_CONTROLLER_SERVER_REMOTE_THREAD_COUNT = "blur.controller.server.remote.thread.count";
-  public static final String BLUR_CONTROLLER_CACHE_MAX_TIMETOLIVE = "blur.controller.cache.max.timetolive";
-  public static final String BLUR_CONTROLLER_CACHE_MAX_QUERYCACHE_ELEMENTS = "blur.controller.cache.max.querycache.elements";
-  public static final String BLUR_CONTROLLER_REMOTE_FETCH_COUNT = "blur.controller.remote.fetch.count";
-
-  public static final String BLUR_CONTROLLER_RETRY_MAX_MUTATE_RETRIES = "blur.controller.retry.max.mutate.retries";
-  public static final String BLUR_CONTROLLER_RETRY_MAX_DEFAULT_RETRIES = "blur.controller.retry.max.default.retries";
-  public static final String BLUR_CONTROLLER_RETRY_FETCH_DELAY = "blur.controller.retry.fetch.delay";
-  public static final String BLUR_CONTROLLER_RETRY_DEFAULT_DELAY = "blur.controller.retry.default.delay";
-  public static final String BLUR_CONTROLLER_RETRY_MUTATE_DELAY = "blur.controller.retry.mutate.delay";
-  public static final String BLUR_CONTROLLER_RETRY_MAX_FETCH_DELAY = "blur.controller.retry.max.fetch.delay";
-  public static final String BLUR_CONTROLLER_RETRY_MAX_MUTATE_DELAY = "blur.controller.retry.max.mutate.delay";
-  public static final String BLUR_CONTROLLER_RETRY_MAX_DEFAULT_DELAY = "blur.controller.retry.max.default.delay";
-  public static final String BLUR_CONTROLLER_RETRY_MAX_FETCH_RETRIES = "blur.controller.retry.max.fetch.retries";
-
-  public static final String BLUR_GUI_CONTROLLER_PORT = "blur.gui.controller.port";
-  public static final String BLUR_GUI_SHARD_PORT = "blur.gui.shard.port";
-
-  public static final String DEFAULT = "default";
-  public static final String BLUR_CLUSTER_NAME = "blur.cluster.name";
-  public static final String BLUR_CLUSTER;
-
-  public static final long ZK_WAIT_TIME = TimeUnit.SECONDS.toMillis(5);
-
-  public static final Term PRIME_DOC_TERM = new Term(PRIME_DOC, BlurConstants.PRIME_DOC_VALUE);
-  public static final Field PRIME_DOC_FIELD = new Field(PRIME_DOC, PRIME_DOC_VALUE, Store.YES, Index.NOT_ANALYZED_NO_NORMS);
-
-  static {
-    try {
-      BlurConfiguration configuration = new BlurConfiguration();
-      BLUR_CLUSTER = configuration.get(BLUR_CLUSTER_NAME, DEFAULT);
-    } catch (IOException e) {
-      throw new RuntimeException("Unknown error parsing configuration.", e);
-    }
-  }
-
-  public static int getPid() {
-    return 0;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurExecutorCompletionService.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurExecutorCompletionService.java b/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurExecutorCompletionService.java
deleted file mode 100644
index 1e5638c..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurExecutorCompletionService.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package com.nearinfinity.blur.utils;
-
-/**
- * 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.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import com.nearinfinity.blur.thrift.BException;
-import com.nearinfinity.blur.thrift.generated.BlurException;
-
-public class BlurExecutorCompletionService<T> extends ExecutorCompletionService<T> {
-
-  private AtomicInteger count = new AtomicInteger(0);
-  private Collection<Future<T>> _bag;
-  private Cancel _cancel;
-
-  public interface Cancel {
-    void cancel();
-  }
-
-  public BlurExecutorCompletionService(Executor executor, Cancel cancel) {
-    super(executor);
-    _bag = Collections.synchronizedCollection(new HashSet<Future<T>>());
-    _cancel = cancel;
-  }
-
-  public void cancelAll() {
-    for (Future<T> future : _bag) {
-      future.cancel(true);
-    }
-    _cancel.cancel();
-  }
-
-  private Future<T> remember(Future<T> future) {
-    _bag.add(future);
-    return future;
-  }
-
-  private Future<T> forget(Future<T> future) {
-    _bag.remove(future);
-    return future;
-  }
-
-  public int getRemainingCount() {
-    return count.get();
-  }
-
-  @Override
-  public Future<T> poll() {
-    Future<T> poll = super.poll();
-    if (poll != null) {
-      count.decrementAndGet();
-    }
-    return forget(poll);
-  }
-
-  @Override
-  public Future<T> poll(long timeout, TimeUnit unit) throws InterruptedException {
-    Future<T> poll = super.poll(timeout, unit);
-    if (poll != null) {
-      count.decrementAndGet();
-    }
-    return forget(poll);
-  }
-
-  @Override
-  public Future<T> submit(Callable<T> task) {
-    Future<T> future = super.submit(task);
-    count.incrementAndGet();
-    return remember(future);
-  }
-
-  @Override
-  public Future<T> submit(Runnable task, T result) {
-    Future<T> future = super.submit(task, result);
-    count.incrementAndGet();
-    return remember(future);
-  }
-
-  @Override
-  public Future<T> take() throws InterruptedException {
-    Future<T> take = super.take();
-    if (take != null) {
-      count.decrementAndGet();
-    }
-    return forget(take);
-  }
-
-  public Future<T> poll(long timeout, TimeUnit unit, boolean throwExceptionIfTimeout, Object... parameters) throws BlurException {
-    try {
-      Future<T> future = poll(timeout, unit);
-      if (future == null) {
-        throw new BException("Call timeout [{0}]", Arrays.asList(parameters));
-      }
-      return future;
-    } catch (InterruptedException e) {
-      throw new BException("Call interrupted [{0}]", e, Arrays.asList(parameters));
-    }
-  }
-
-  public T getResultThrowException(Future<T> future, Object... parameters) throws BlurException {
-    try {
-      return future.get();
-    } catch (InterruptedException e) {
-      throw new BException("Call interrupted [{0}]", e, Arrays.asList(parameters));
-    } catch (ExecutionException e) {
-      throw new BException("Call execution exception [{0}]", e.getCause(), Arrays.asList(parameters));
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/33df9310/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurThriftRecord.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurThriftRecord.java b/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurThriftRecord.java
deleted file mode 100644
index a73214c..0000000
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/utils/BlurThriftRecord.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.nearinfinity.blur.utils;
-
-/**
- * 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 com.nearinfinity.blur.thrift.generated.Column;
-import com.nearinfinity.blur.thrift.generated.Record;
-
-public class BlurThriftRecord extends Record implements ReaderBlurRecord {
-
-  private static final long serialVersionUID = 1447192115360284850L;
-
-  @Override
-  public void addColumn(String name, String value) {
-    addToColumns(new Column(name, value));
-  }
-
-  @Override
-  public void setRecordIdStr(String value) {
-    setRecordId(value);
-  }
-
-  @Override
-  public void setFamilyStr(String family) {
-    setFamily(family);
-  }
-
-  @Override
-  public void setRowIdStr(String rowId) {
-    // setRowIdStr(rowId);
-  }
-
-}


Mime
View raw message