Fixed BLUR-133
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/b20524d7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/b20524d7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/b20524d7 Branch: refs/heads/0.1.5 Commit: b20524d77d7272034d775c0643ff96395dbca03d Parents: 126517e Author: Aaron McCurry <[email protected]> Authored: Mon Jun 10 21:50:14 2013 -0400 Committer: Aaron McCurry <[email protected]> Committed: Mon Jun 10 21:50:14 2013 -0400 ---------------------------------------------------------------------- .../clusterstatus/ZookeeperClusterStatus.java | 42 ++++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b20524d7/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 4e84d08..6354366 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 @@ -28,6 +28,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -393,20 +394,35 @@ public class ZookeeperClusterStatus extends ClusterStatus { TableDescriptor tableDescriptor = new TableDescriptor(); try { checkIfOpen(); - tableDescriptor.shardCount = Integer.parseInt(new String(getData(ZookeeperPathConstants.getTableShardCountPath(cluster, table)))); - tableDescriptor.tableUri = new String(getData(ZookeeperPathConstants.getTableUriPath(cluster, table))); - tableDescriptor.compressionClass = new String(getData(ZookeeperPathConstants.getTableCompressionCodecPath(cluster, table))); - tableDescriptor.compressionBlockSize = Integer.parseInt(new String(getData(ZookeeperPathConstants.getTableCompressionBlockSizePath(cluster, table)))); - tableDescriptor.analyzerDefinition = fromBytes(getData(ZookeeperPathConstants.getTablePath(cluster, table)), AnalyzerDefinition.class); - tableDescriptor.blockCaching = isBlockCacheEnabled(cluster, table); - tableDescriptor.blockCachingFileTypes = getBlockCacheFileTypes(cluster, table); - tableDescriptor.name = table; - tableDescriptor.columnPreCache = fromBytes(getData(ZookeeperPathConstants.getTableColumnsToPreCache(cluster, table)), ColumnPreCache.class); - byte[] data = getData(ZookeeperPathConstants.getTableSimilarityPath(cluster, table)); - if (data != null) { - tableDescriptor.similarityClass = new String(data); + NullPointerException npe = null; + LOOP: + for (int i = 0; i < 10; i++) { + npe = null; + try { + tableDescriptor.shardCount = Integer.parseInt(new String(getData(ZookeeperPathConstants.getTableShardCountPath(cluster, table)))); + tableDescriptor.tableUri = new String(getData(ZookeeperPathConstants.getTableUriPath(cluster, table))); + tableDescriptor.compressionClass = new String(getData(ZookeeperPathConstants.getTableCompressionCodecPath(cluster, table))); + tableDescriptor.compressionBlockSize = Integer.parseInt(new String(getData(ZookeeperPathConstants.getTableCompressionBlockSizePath(cluster, table)))); + tableDescriptor.analyzerDefinition = fromBytes(getData(ZookeeperPathConstants.getTablePath(cluster, table)), AnalyzerDefinition.class); + tableDescriptor.blockCaching = isBlockCacheEnabled(cluster, table); + tableDescriptor.blockCachingFileTypes = getBlockCacheFileTypes(cluster, table); + tableDescriptor.name = table; + tableDescriptor.columnPreCache = fromBytes(getData(ZookeeperPathConstants.getTableColumnsToPreCache(cluster, table)), ColumnPreCache.class); + byte[] data = getData(ZookeeperPathConstants.getTableSimilarityPath(cluster, table)); + if (data != null) { + tableDescriptor.similarityClass = new String(data); + } + updateReadOnlyAndEnabled(useCache, tableDescriptor, cluster, table); + break LOOP; + } catch (NullPointerException e) { + npe = e; + LOG.warn("Terrible hack to make the table admins pick up on changes to table descriptors while it's being created."); + Thread.sleep(TimeUnit.SECONDS.toMillis(3)); + } + } + if (npe != null) { + throw npe; } - updateReadOnlyAndEnabled(useCache, tableDescriptor, cluster, table); } catch (KeeperException e) { throw new RuntimeException(e); } catch (InterruptedException e) {
