Fixed BLUR-298
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/2df8399e Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/2df8399e Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/2df8399e Branch: refs/heads/apache-blur-0.2 Commit: 2df8399e575f9af0eec780ee63d4a0b61bd0e6b4 Parents: e3f18c3 Author: Aaron McCurry <[email protected]> Authored: Wed Nov 20 09:27:59 2013 -0500 Committer: Aaron McCurry <[email protected]> Committed: Wed Nov 20 09:27:59 2013 -0500 ---------------------------------------------------------------------- .../manager/clusterstatus/ClusterStatus.java | 7 ----- .../clusterstatus/ZookeeperClusterStatus.java | 27 ++------------------ .../indexserver/DistributedIndexServer.java | 6 +++-- .../blur/thrift/BlurControllerServer.java | 3 ++- .../apache/blur/manager/IndexManagerTest.java | 18 +------------ 5 files changed, 9 insertions(+), 52 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2df8399e/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java index 32110ff..4ea5801 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java +++ b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ClusterStatus.java @@ -18,7 +18,6 @@ package org.apache.blur.manager.clusterstatus; */ import java.util.ArrayList; import java.util.List; -import java.util.Set; import org.apache.blur.thrift.generated.TableDescriptor; @@ -59,12 +58,6 @@ public abstract class ClusterStatus { return shardServerList; } - public abstract int getShardCount(boolean useCache, String cluster, String table); - - public abstract boolean isBlockCacheEnabled(String cluster, String table); - - public abstract Set<String> getBlockCacheFileTypes(String cluster, String table); - public abstract List<String> getTableList(boolean useCache, String cluster); public abstract boolean isReadOnly(boolean useCache, String cluster, String table); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2df8399e/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java index bf2592e..d7e1a2f 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java +++ b/blur-core/src/main/java/org/apache/blur/manager/clusterstatus/ZookeeperClusterStatus.java @@ -660,29 +660,7 @@ public class ZookeeperClusterStatus extends ClusterStatus { } } - @Override - public int getShardCount(boolean useCache, String cluster, String table) { - if (useCache) { - TableDescriptor tableDescriptor = getTableDescriptor(true, cluster, table); - return tableDescriptor.shardCount; - } - long s = System.nanoTime(); - try { - return Integer.parseInt(new String(getData(ZookeeperPathConstants.getTableShardCountPath(cluster, table)))); - } catch (NumberFormatException e) { - throw new RuntimeException(e); - } catch (KeeperException e) { - throw new RuntimeException(e); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } finally { - long e = System.nanoTime(); - LOG.debug("trace getShardCount took [" + (e - s) / 1000000.0 + " ms]"); - } - } - - @Override - public Set<String> getBlockCacheFileTypes(String cluster, String table) { + private Set<String> getBlockCacheFileTypes(String cluster, String table) { long s = System.nanoTime(); try { byte[] data = getData(ZookeeperPathConstants.getTableBlockCachingFileTypesPath(cluster, table)); @@ -708,8 +686,7 @@ public class ZookeeperClusterStatus extends ClusterStatus { } } - @Override - public boolean isBlockCacheEnabled(String cluster, String table) { + private boolean isBlockCacheEnabled(String cluster, String table) { long s = System.nanoTime(); try { checkIfOpen(); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2df8399e/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java b/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java index 2e548d2..fa38de6 100644 --- a/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java +++ b/blur-core/src/main/java/org/apache/blur/manager/indexserver/DistributedIndexServer.java @@ -453,9 +453,11 @@ public class DistributedIndexServer extends AbstractDistributedIndexServer { ShardContext shardContext = ShardContext.create(tableContext, shard); Directory dir; - boolean blockCacheEnabled = _clusterStatus.isBlockCacheEnabled(_cluster, table); + + TableDescriptor descriptor = tableContext.getDescriptor(); + boolean blockCacheEnabled = descriptor.isBlockCaching(); if (blockCacheEnabled) { - Set<String> blockCacheFileTypes = _clusterStatus.getBlockCacheFileTypes(_cluster, table); + Set<String> blockCacheFileTypes = descriptor.getBlockCachingFileTypes(); dir = _blockCacheDirectoryFactory.newDirectory(table, shard, directory, blockCacheFileTypes); } else { dir = directory; http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2df8399e/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java index ee74504..ed15d34 100644 --- a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java +++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java @@ -349,7 +349,8 @@ public class BlurControllerServer extends TableAdmin implements Iface { String cluster = _clusterStatus.getCluster(true, table); _queryChecker.checkQuery(blurQuery); checkSelectorFetchSize(blurQuery.getSelector()); - int shardCount = _clusterStatus.getShardCount(true, cluster, table); + TableDescriptor tableDescriptor = _clusterStatus.getTableDescriptor(true, cluster, table); + int shardCount = tableDescriptor.getShardCount(); if (blurQuery.getUuid() == null) { blurQuery.setUuid(UUID.randomUUID().toString()); } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2df8399e/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java ---------------------------------------------------------------------- diff --git a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java index fd5f266..48ccab3 100644 --- a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java +++ b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java @@ -42,7 +42,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeSet; import java.util.concurrent.atomic.AtomicLongArray; @@ -60,6 +59,7 @@ import org.apache.blur.thrift.generated.Facet; import org.apache.blur.thrift.generated.FetchRecordResult; import org.apache.blur.thrift.generated.FetchResult; import org.apache.blur.thrift.generated.HighlightOptions; +import org.apache.blur.thrift.generated.Query; import org.apache.blur.thrift.generated.Record; import org.apache.blur.thrift.generated.RecordMutation; import org.apache.blur.thrift.generated.Row; @@ -67,7 +67,6 @@ import org.apache.blur.thrift.generated.RowMutation; import org.apache.blur.thrift.generated.Schema; import org.apache.blur.thrift.generated.ScoreType; import org.apache.blur.thrift.generated.Selector; -import org.apache.blur.thrift.generated.Query; import org.apache.blur.thrift.generated.TableDescriptor; import org.apache.blur.utils.BlurConstants; import org.apache.blur.utils.BlurIterator; @@ -141,11 +140,6 @@ public class IndexManagerTest { } @Override - public boolean isBlockCacheEnabled(String cluster, String table) { - throw new RuntimeException("Not impl"); - } - - @Override public List<String> getTableList(boolean useCache, String cluster) { throw new RuntimeException("Not impl"); } @@ -161,11 +155,6 @@ public class IndexManagerTest { } @Override - public int getShardCount(boolean useCache, String cluster, String table) { - throw new RuntimeException("Not impl"); - } - - @Override public List<String> getOnlineShardServers(boolean useCache, String cluster) { throw new RuntimeException("Not impl"); } @@ -191,11 +180,6 @@ public class IndexManagerTest { } @Override - public Set<String> getBlockCacheFileTypes(String cluster, String table) { - throw new RuntimeException("Not impl"); - } - - @Override public boolean exists(boolean useCache, String cluster, String table) { throw new RuntimeException("Not impl"); }
